应用程序从Activity2Activity.java开始,它是Calling Menu.java。 我能够看到Activity2Activity.java [Main Activity]中的标签,但是当它调用Other Activity Menu.java标签不会出现时。
清单文件:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission
android:name="android.permission.SET_WALLPAPER"
android:maxSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.firsttest.MainActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Activity2Activity"
android:label="@string/title_activity_activity2"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MENU"
android:label="ListMenu" >
<intent-filter>
<action android:name="com.firsttest.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
Activity2Activity.java
public class Activity2Activity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity2);
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
}
catch(InterruptedException e){
e.printStackTrace();
}
finally{
Intent mainActivity = new Intent("com.firsttest.MENU");
startActivity(mainActivity);
}
}
};
timer.start();
}
@Override
protected void onPause(){
super.onPause();
finish();
}
Menu.java
public class MENU extends ListActivity{
String classes[]={"Activity2Activity","TextPlay","Email","Camera","Data","example5"};
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
//setContentView(R.layout.activity2);
String cheese=classes[position];
Class ourClass;
try {
ourClass = Class.forName("com.example.firsttest."+cheese);
Intent ourIntent = new Intent(MENU.this,ourClass);
startActivity(ourIntent);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Log.i("TagX", "Inside onCreate");
setListAdapter(new ArrayAdapter<String>(MENU.this,android.R.layout.simple_list_item_1,classes));
}
}
答案 0 :(得分:0)
以编程方式在menu.java文件中设置标题。
getSupportActionBar().setTitle("Your Title");
OR
DatabaseHelper
答案 1 :(得分:0)
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.menu);
this.setTitle("myclass2");
试试这个。告诉我它是否有效