Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. import android.content.SharedPreferences;
  2. import android.support.v7.app.ActionBarActivity;
  3. import android.os.Bundle;
  4. import android.view.Menu;
  5. import android.view.MenuItem;
  6. import android.widget.TextView;
  7.  
  8. import org.w3c.dom.Text;
  9.  
  10.  
  11. public class MainActivity2Activity extends ActionBarActivity {
  12.  
  13. @Override
  14. protected void onCreate(Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16. setContentView(R.layout.activity_main_activity2);
  17.  
  18. // GET REFERENCE TO THE TEXTFIELD
  19. TextView tvText = (TextView)findViewById(R.id.tvText);
  20. // READ DATA FROM SHAREDPREFERENCES
  21. SharedPreferences preferences = MainActivity.mySharedPreferences;
  22. String values = preferences.getString("values","");
  23.  
  24. // DISPLAY DATA FROM SHAREDPREFERENCES
  25. tvText.setText(values);
  26. }
  27.  
  28.  
  29. @Override
  30. public boolean onCreateOptionsMenu(Menu menu) {
  31. // Inflate the menu; this adds items to the action bar if it is present.
  32. getMenuInflater().inflate(R.menu.menu_main_activity2, menu);
  33. return true;
  34. }
  35.  
  36. @Override
  37. public boolean onOptionsItemSelected(MenuItem item) {
  38. // Handle action bar item clicks here. The action bar will
  39. // automatically handle clicks on the Home/Up button, so long
  40. // as you specify a parent activity in AndroidManifest.xml.
  41. int id = item.getItemId();
  42.  
  43. //noinspection SimplifiableIfStatement
  44. if (id == R.id.action_settings) {
  45. return true;
  46. }
  47.  
  48. return super.onOptionsItemSelected(item);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement