我实现了我的Android应用程序的启动画面....我的操作栏中有一个自定义主页按钮,点击后,它将被重定向到我的仪表板活动,而不是我的启动画面..你有吗?任何想法如何实现它?我是Android应用程序的新手......
请告诉我该怎么做..我不知道如何编码......
任何回应都非常感谢。谢谢
我的菜单项代码
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menuitem1:
//code to be inserted here but I dont know how
break;
case R.id.menuitem2:
Log.i("This is Menu", "0");
super.onBackPressed();
break;
default:
break;
}
return true;
}
我的Android Manifest
<activity android:name=".SplashScreen"
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AndroidTabLayoutActivity"
android:logo="@drawable/logo"
android:label=""
>
<intent-filter>
<action android:name="com.droidnova.android.splashscreen.AndroidTabLayoutActivity" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
答案 0 :(得分:0)
您可以使用startActivity(<Intent for your dashboard activity>)
代替super.onBackPressed()
。
答案 1 :(得分:0)
在OnClick主页按钮启动仪表板活动
home.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(currentclass.this,dashboardactivity.class);
startActivity(intent);
finish();
}
});
答案 2 :(得分:0)
您说仪表板是AndroidTabLayoutActivity中的一个片段。我想你不想从当前的活动中调用那个片段。
您可以在意图中传递一个参数来打开AndroidTabLayoutActivity,就像这样。 (此代码在onOptionsItemSelected()方法中)
Intent intent = new Intent();
intent.setClass(this,AndroidTabLayoutActivity.class);
intent.putExtra("type","dashboard");
startActivity(intent);
然后在onCreate方法的AndroidTabLayoutActivity中,您可以检查此参数是否存在。
if ( getIntent().getStringExtra("type","splash").equals("dashboard")) {
//start dashboard
} else {
//start splashscreen
}