我有一个活动,我想用它在我的列表视图中打开意图,但是在我的列表视图中使用StrawberryShake看起来不太好,当它用作活动名称时,有一种方法可以重命名在android中向活动名称添加空间,以便在列表视图中看起来像
例A 例B 示例C
而不是
ExampleA ExampleB ExampleC
这是我的密码
//列表中的示例项目静态最终String[]防波堤={ "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();
}
}发布于 2013-09-20 20:09:34
您一定是在谈论活动顶部出现的标签,您可以在报表中自定义它
<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>@Deprecated
或者简单地说(但不推荐硬编码字符串,它会在应用程序的全球化中产生问题)
<activity
android:name=".MainActivity"
android:icon="@drawable/icon_small"
android:label="My Activity Name">
</activity>编辑:
对于您的问题,您可以使用类似于DisplayText & ValueText对或
在标记中添加activityName,在文本字段中添加DisplayName
或者,您可以使用额外的TextView和Visibility="Gone"。
https://stackoverflow.com/questions/18924977
复制相似问题