我正在尝试使用这样的 switch 语句开始活动:
public class MainActivity extends AppCompatActivity {
public static String key = "1010";
private Bitmap bitmap = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
this.getMenuInflater().inflate(R.menu.items, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.add:
//working
break;
case R.id.rotate_right:
//working
break;
case R.id.fullscreen: //not working
Intent intent = new Intent(getBaseContext(), fullScreenActivity.class);
intent.putExtra(key, bitmap);
startActivity(intent);
break;
}
}
}
这就是下一个活动的代码
public class fullScreenActivity extends AppCompatActivity {
Bitmap bitmap = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_screen);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Intent starter = getIntent();
bitmap = starter.getParcelableExtra(MainActivity.key);
}
}
我还在清单中添加了第二个活动:
<activity android:name=".fullScreenActivity"
android:screenOrientation="landscape"></activity>
这是 R.menu.items:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/add"
android:icon="@drawable/ic_add_black_24dp"
android:title="@string/add_item"
app:showAsAction="ifRoom"
/>
它什么也没做,那可能是什么问题?
请注意,只有全屏项目不起作用,所以我认为问题出在 startActivity 代码中。
慕雪6442864
慕尼黑5688855
相关分类