Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. <Button
  2. android:id="@+id/button2"
  3. style="?android:attr/buttonStyleSmall"
  4. android:layout_width="wrap_content"
  5. android:layout_height="wrap_content"
  6. android:layout_alignParentBottom="true"
  7. android:layout_alignParentLeft="true"
  8. android:background="#FFFFFF"
  9. android:text="@string/info_btn" />
  10.  
  11. package ie.gmit.project;
  12.  
  13. import android.support.v7.app.ActionBarActivity;
  14. import android.support.v7.app.ActionBar;
  15. import android.support.v4.app.Fragment;
  16. import android.content.Intent;
  17. import android.net.Uri;
  18. import android.os.Bundle;
  19. import android.view.LayoutInflater;
  20. import android.view.Menu;
  21. import android.view.MenuItem;
  22. import android.view.View;
  23. import android.view.ViewGroup;
  24. import android.widget.Button;
  25. import android.os.Build;
  26.  
  27. public class MainActivity extends ActionBarActivity {
  28.  
  29. @Override
  30. protected void onCreate(Bundle savedInstanceState) {
  31. super.onCreate(savedInstanceState);
  32. setContentView(R.layout.activity_main);
  33.  
  34. if (savedInstanceState == null) {
  35. getSupportFragmentManager().beginTransaction()
  36. .add(R.id.container, new PlaceholderFragment())
  37. .commit();
  38. }
  39. }
  40.  
  41. public void openSite(View v){
  42. Uri uri = Uri.parse("http://gmitsu.ie/clubssocs/directory.html");
  43. Intent intent = new Intent(Intent.ACTION_VIEW, uri);
  44. startActivity(intent);
  45. }
  46.  
  47.  
  48. @Override
  49. public boolean onCreateOptionsMenu(Menu menu) {
  50.  
  51. // Inflate the menu; this adds items to the action bar if it is present.
  52. getMenuInflater().inflate(R.menu.main, menu);
  53. return true;
  54. }
  55.  
  56. @Override
  57. public boolean onOptionsItemSelected(MenuItem item) {
  58. // Handle action bar item clicks here. The action bar will
  59. // automatically handle clicks on the Home/Up button, so long
  60. // as you specify a parent activity in AndroidManifest.xml.
  61. int id = item.getItemId();
  62. if (id == R.id.action_settings) {
  63. return true;
  64. }
  65. return super.onOptionsItemSelected(item);
  66. }
  67.  
  68. /**
  69. * A placeholder fragment containing a simple view.
  70. */
  71. public static class PlaceholderFragment extends Fragment {
  72.  
  73. public PlaceholderFragment() {
  74. }
  75.  
  76. @Override
  77. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  78. Bundle savedInstanceState) {
  79. View rootView = inflater.inflate(R.layout.fragment_main, container, false);
  80. return rootView;
  81. }
  82. }
  83.  
  84. public class MainActivity extends Activity {
  85.  
  86. private Button button2;//this is a bad name
  87.  
  88. @Override
  89. protected void onCreate(Bundle savedInstanceState) {
  90. super.onCreate(savedInstanceState);
  91. setContentView(R.layout.main_activity);
  92.  
  93. button2= (Button) findViewById(R.id.button2);//find the button
  94.  
  95.  
  96. button2.setOnClickListener(new View.OnClickListener() {
  97.  
  98. @Override
  99. public void onClick(View v) {
  100. Intent i = new Intent(v.getContext(), InfoActivity.class);
  101. startActivity(i);
  102. finish();//if you want to close main activity after start info activity
  103. });
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement