gpt4 book ai didi

java - 为什么我无法显示默认的 Android 行选择颜色?

转载 作者:行者123 更新时间:2023-12-02 08:05:39 26 4
gpt4 key购买 nike

我正在使用此代码来实现 ListView 部分:

  public class ListSample extends ListActivity implements OnItemClickListener{   

public final static String ITEM_TITLE = "title";
public final static String ITEM_CAPTION = "caption";
public Resources resources;
public static Uri path;
ImageAdapter customAdapter;
private SeparatedListAdapter adapter;
public static File file;
public static ProgressDialog m_progressDialog;
public static ListView list;

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);

// create our list and custom adapter
adapter = new SeparatedListAdapter(this);

// customAdapter =new ImageAdapter(ListSample.this, R.layout.list_item,mList);

adapter.addSection("Local documents:", new ArrayAdapter<String>(this,
R.layout.list_item, new String[] { "WindowsONE Mobile PK", "WindowsorONE Moldings","Filet for a burger video" }));
adapter.addSection("Non-local resources:", new ArrayAdapter<String>(this,
R.layout.list_item, new String[] { "Launch Photo slideshow link", "Dealer locator link" }));
adapter.addSection("Send emails:", new ArrayAdapter<String>(this,
R.layout.list_item, new String[] { "Send Dealer Locator email", "Send Catalog email","Send install instrucation link" }));
//For extra Information in Listview
//adapter.addSection("Non-local resources:", new SimpleAdapter(this, security, R.layout.list_complex,
//new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[] { R.id.list_complex_title, R.id.list_complex_caption }));
list = getListView();
list.setAdapter(adapter);
list.setTextFilterEnabled(true);
list.setOnItemClickListener(this);
}
}

如果我运行这个应用程序,一切正常。
但是,当选择任何行时,操作已完成,但我看不到任何突出显示颜色,就像选择了该行一样(就像默认的 android 行选择颜色一样)。

那么,我应该做什么才能使它成为可能?

我想在选择特定行时显示突出显示颜色。

最佳答案

您的 rowitem.xml 必须具有背景颜色。删除它,您将看到默认的突出显示颜色。如果您想自定义突出显示,请按照 Flybirdx 建议使用选择器

关于java - 为什么我无法显示默认的 Android 行选择颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8212383/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com