私の活動に関するオプションメニューがあります。 、オプションメニューで空白の画面が表示される
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent = new Intent();
switch (item.getItemId()) {
case R.id.some_menu:
intent.setComponent(new ComponentName(MyActivity.this,SomeActivity.class));
startActivity(intent);
return true;
case R.id.someother_menu:
intent.setComponent(new ComponentName(MyActivity.this, SomeOtherActivity.class));
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
まずメニュー、some_menu
を正常に動作している:私は、法の下に使用してオプションメニューのクリックで別のアクティビティを表示しています。上記のアクティビティが表示されます。ただし、2番目のメニューsomeother_menu
をクリックすると、黒い空白の画面が表示されます。何が起こっているのか分かりません。 SomeOtherActivityため
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/follow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25sp"
/>
<ListView
android:id="@+id/follow_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</LinearLayout>
をあなたの 'SomeOtherActivity'のコードを投稿してください。 'setContentView(R.layout.your_layout)'を呼ぶのを忘れてしまったと思います。 – WarrenFaith
私は "SomeOtherActivity"のsetContentViewを持っています。protected void onCreate(Bundle savedInstanceState){ \t \t super.onCreate(savedInstanceState); \t \t setContentView(R.layout.follow); } – Reena
あなたはレイアウトに何かが表示されていると確信していますか?あなたの質問にxmlを追加してください。コメントではありません。ありがとう。 – WarrenFaith