首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在活动名称之间添加空格

如何在活动名称之间添加空格
EN

Stack Overflow用户
提问于 2013-09-20 20:06:17
回答 1查看 371关注 0票数 0

我有一个活动,我想用它在我的列表视图中打开意图,但是在我的列表视图中使用StrawberryShake看起来不太好,当它用作活动名称时,有一种方法可以重命名在android中向活动名称添加空间,以便在列表视图中看起来像

例A 例B 示例C

而不是

ExampleA ExampleB ExampleC

这是我的密码

//列表中的示例项目静态最终String[]防波堤={ "Strawberry_Shake",};

代码语言:javascript
复制
@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();
    }
}
EN

回答 1

Stack Overflow用户

发布于 2013-09-20 20:09:34

您一定是在谈论活动顶部出现的标签,您可以在报表中自定义它

代码语言:javascript
复制
    <activity
        android:name=".MainActivity"
        android:icon="@drawable/icon_small"
        android:label="@string/MyActivityName">
    </activity>

然后在strings.xml

代码语言:javascript
复制
   <string name="MyActivityName">My Activity Name</string>

甚至您也可以使用下面的html标记

代码语言:javascript
复制
   <string name="MyActivityName"><b><i>My Activity Name</i></b></string>

@Deprecated

或者简单地说(但不推荐硬编码字符串,它会在应用程序的全球化中产生问题)

代码语言:javascript
复制
<activity
    android:name=".MainActivity"
    android:icon="@drawable/icon_small"
    android:label="My Activity Name">
</activity>

编辑:

对于您的问题,您可以使用类似于DisplayText & ValueText对或

在标记中添加activityName,在文本字段中添加DisplayName

或者,您可以使用额外的TextView和Visibility="Gone"

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18924977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档