Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. package com.example.apka2;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.support.v7.app.ActionBarActivity;
  7. import android.view.Menu;
  8. import android.view.MenuItem;
  9. import android.view.View;
  10. import android.view.View.OnClickListener;
  11. import android.widget.Button;
  12. import android.widget.EditText;
  13. import android.widget.RadioButton;
  14. import android.widget.RadioGroup;
  15. import android.widget.RatingBar;
  16. import android.widget.TextView;
  17.  
  18. public class MainActivity extends ActionBarActivity {
  19.  
  20. TextView tytul;
  21. RatingBar ocena;
  22. RadioGroup plec;
  23. EditText imie;
  24. Button but;
  25. Context context;
  26.  
  27. @Override
  28. protected void onCreate(Bundle savedInstanceState) {
  29. super.onCreate(savedInstanceState);
  30. setContentView(R.layout.activity_main);
  31. context= getApplicationContext();
  32.  
  33. tytul=(TextView)findViewById(R.id.tytul);
  34. ocena=(RatingBar)findViewById(R.id.ratingBar);
  35. plec=(RadioGroup)findViewById(R.id.plec);
  36. imie=(EditText)findViewById(R.id.editText1);
  37. but=(Button)findViewById(R.id.button1);
  38.  
  39. tytul.setText("elite haxor");
  40. but.setText("OK!hehehehehhe");
  41.  
  42. but.setOnClickListener(new OnClickListener() {
  43.  
  44. public void onClick(View v) {
  45. //Toast.makeText(context, "pls dun hurt me gurl dun, no moar", Toast.LENGTH_LONG).show();
  46. Intent intent=new Intent(context, Ekran2Activity.class);
  47.  
  48. RadioButton radioButton=(RadioButton)plec.findViewById(plec.getCheckedRadioButtonId());
  49. String tytulString= tytul.getText().toString();
  50.  
  51. intent.putExtra("tytul",tytulString);
  52. intent.putExtra("plec", radioButton.getText());
  53. intent.putExtra("ocena", ocena.getRating());
  54.  
  55. startActivity(intent);
  56. }
  57. });
  58.  
  59.  
  60.  
  61. }
  62.  
  63. @Override
  64. public boolean onCreateOptionsMenu(Menu menu) {
  65. // Inflate the menu; this adds items to the action bar if it is present.
  66. getMenuInflater().inflate(R.menu.main, menu);
  67. return true;
  68. }
  69.  
  70. @Override
  71. public boolean onOptionsItemSelected(MenuItem item) {
  72. // Handle action bar item clicks here. The action bar will
  73. // automatically handle clicks on the Home/Up button, so long
  74. // as you specify a parent activity in AndroidManifest.xml.
  75. int id = item.getItemId();
  76. if (id == R.id.action_settings) {
  77. return true;
  78. }
  79. return super.onOptionsItemSelected(item);
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement