首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ContextMenu从右到左

ContextMenu从右到左
EN

Stack Overflow用户
提问于 2016-04-05 17:21:54
回答 2查看 451关注 0票数 1

我有一个contextMenu,它由编辑和删除两个项目组成!但是因为我正在写我的国家,所以language...Items应该是正确的对齐!下面是我的代码。请指导me.Thank!

代码语言:javascript
复制
public class ListActivity extends AppCompatActivity {
ListView lst_data;
DicDBAdapter dicDBAdapter;
Dic dic;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    lst_data = (ListView) findViewById(R.id.lst_data);
    dicDBAdapter = new DicDBAdapter(getApplicationContext());
    ArrayList<String> arrayList = dicDBAdapter.getdata();
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getApplicationContext(),
            android.R.layout.simple_dropdown_item_1line,
            arrayList);
    lst_data.setAdapter(arrayAdapter);
    registerForContextMenu(lst_data);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    getMenuInflater().inflate(R.menu.context, menu);


}

}

EN

回答 2

Stack Overflow用户

发布于 2016-04-05 17:44:55

用下面的代码创建一个布局文件。

代码语言:javascript
复制
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/text1"
    style="?android:attr/dropDownItemStyle"
    android:textAppearance="?android:attr/textAppearanceLargePopupMenu"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:gravity="start"
    android:ellipsize="marquee" />

在创建数组适配器时,将此布局作为项传递。

代码语言:javascript
复制
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getApplicationContext(),
            R.layout.new_layout,
            arrayList);
票数 0
EN

Stack Overflow用户

发布于 2018-12-26 20:07:31

您可以在listView中更改layoutDirection

代码语言:javascript
复制
<ListView
    android:layout_width="wrap_content"
    android:layoutDirection="rtl"
    android:layout_height="wrap_content"/>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36422162

复制
相关文章

相似问题

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