我有一个活动,我想用它来打开我的列表视图中的意图,但是当我用作活动名称时,使用StrawberryShake在我的列表视图中看起来不太好,可以将一个方法重命名为活动名称android以便在列表视图中看起来像
示例A
例B
示例C
而不是
例A
例B
ExampleC
这是我的代码
//列表中的示例项目 static final String [] breakfood = { “Strawberry_Shake” };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, breakfood));
// Setting up the list array above
}
// Setting the onlick listener so the array will open up activity
protected void onListItemClick(ListView lv, View v, int position, long id){
super.onListItemClick(lv, v, position, id);
String openbreakclass = breakfood[position];
try{
// Using the class name to open up the activity from the previous array but its
//displaying the dash in the list
Class selected = Class.forName("com.example.yummini."+ openbreakclass);
Intent selectedIntent = new Intent(this, selected);
startActivity(selectedIntent);
}catch (ClassNotFoundException e){
e.printStackTrace();
}
}
答案 0 :(得分:4)
您必须谈论标签显示在活动的顶部,您可以在清单中自定义
<activity
android:name=".MainActivity"
android:icon="@drawable/icon_small"
android:label="@string/MyActivityName">
</activity>
然后在strings.xml中
<string name="MyActivityName">My Activity Name</string>
即使你可以使用一些html标签,如
<string name="MyActivityName"><b><i>My Activity Name</i></b></string>
或简单(但不推荐硬编码字符串,它会在应用程序的全球化中产生问题)
<activity
android:name=".MainActivity"
android:icon="@drawable/icon_small"
android:label="My Activity Name">
</activity>
修改:
对于您的问题,您可以使用类似这样的显示文本&amp; ValueText对或
在标签中添加activityName,在文本字段中添加DisplayName
或者您可以使用Visibility="Gone"