Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 2.17 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Blank screen displayed on option menu click
  2. @Override
  3. public boolean onOptionsItemSelected(MenuItem item) {
  4.  
  5.     Intent intent = new Intent();
  6.  
  7.     switch (item.getItemId()) {
  8.  
  9.     case R.id.some_menu:
  10.         intent.setComponent(new ComponentName(MyActivity.this,SomeActivity.class));
  11.         startActivity(intent);
  12.         return true;
  13.  
  14.     case R.id.someother_menu:
  15.         intent.setComponent(new ComponentName(MyActivity.this, SomeOtherActivity.class));
  16.         startActivity(intent);
  17.         return true;
  18.  
  19.     default:
  20.         return super.onOptionsItemSelected(item);
  21.     }
  22. }
  23.        
  24. <?xml version="1.0" encoding="utf-8"?>
  25. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  26. android:layout_width="match_parent"
  27. android:layout_height="match_parent"
  28. android:orientation="vertical" >
  29.  
  30. <TextView
  31.     android:id="@+id/follow"
  32.     android:layout_width="match_parent"
  33.     android:layout_height="wrap_content"
  34.     android:textSize="25sp"
  35.     />
  36.  
  37. <ListView
  38.     android:id="@+id/follow_list"
  39.     android:layout_width="fill_parent"
  40.     android:layout_height="fill_parent">
  41. </ListView>
  42. </LinearLayout>
  43.        
  44. <?xml version="1.0" encoding="utf-8"?>
  45. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  46.      android:layout_width="match_parent" android:layout_height="match_parent"  
  47.      android:orientation="vertical" >
  48.  
  49. <TextView
  50.     android:id="@+id/follow"
  51.     android:layout_width="match_parent"
  52.     android:layout_height="wrap_content"
  53.     android:textSize="25sp"
  54.     android:text="DUMMYTEXT"
  55.     />
  56.  
  57. <ListView
  58.     android:id="@+id/follow_list"
  59.     android:layout_width="fill_parent"
  60.     android:layout_height="fill_parent">
  61. </ListView>
  62. </LinearLayout>
  63.        
  64. @Override
  65. public boolean onOptionsItemSelected(MenuItem item) {
  66.  
  67.     Intent intent = new Intent();
  68.  
  69.     switch (item.getItemId()) {
  70.  
  71.     case R.id.some_menu:
  72.         intent.setComponent(new ComponentName(MyActivity.this,SomeActivity.class));
  73.         startActivity(intent);
  74.         return true;
  75.  
  76.     case R.id.someother_menu:
  77.         intent.setComponent(new ComponentName(MyActivity.this, SomeOtherActivity.class));
  78.         startActivity(intent);
  79.         return true;
  80.     }
  81.     return super.onOptionsItemSelected(item);
  82. }