如何摆脱选择圈?

时间:2016-07-21 04:04:57

标签: android listview

我目前正在尝试在Android Studio项目中使用ListView。

我试图实现onSelectedListener,但它一直没有选择,所以我不得不使用onClickListener。

问题是列表项上的选择圈仍然存在,但现在我没有使用onClickListener而不是onSelect。

如何删除列表项上的这些选择圈?

在相关说明中,如果可能,您能找到onSelected在我的ListView上无效的原因吗?

的ListView:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:descendantFocusability="blocksDescendants"
    >
    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </ListView>
</LinearLayout>

适配器:

final AlertDialog.Builder ExceedingLimitDialog = new AlertDialog.Builder(SettingsMenu.this);
                //Storing Original value
                final int OriginalExceed = PhoneBelt.getExceedInt();
                //Setting ListView
                LayoutInflater inflater = getLayoutInflater();
                View convertView = inflater.inflate(R.layout.exceeding_dialog, null);
                lv = (ListView) convertView.findViewById(R.id.list);
                ArrayAdapter<String> adapter = new ArrayAdapter<>(SettingsMenu.this, android.R.layout.simple_list_item_single_choice, ExceedingSelection);
                lv.setAdapter(adapter);
                lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        int SelectedItem = Integer.parseInt(ExceedingSelection[position]);
                        PhoneBelt.setExceedInt(SelectedItem);
                        Toast toast = Toast.makeText(SettingsMenu.this, "You have selected" + SelectedItem, Toast.LENGTH_LONG);
                        toast.show();
                    }
                });
                ExceedingLimitDialog.setView(convertView);
                ExceedingLimitDialog.setTitle(R.string.Exceeding_Limit_Title);
                ExceedingLimitDialog.setMessage(R.string.Exceeding_Limit_Message);
                ExceedingLimitDialog.setCancelable(true);

                AlertDialog alert = ExceedingLimitDialog.create();
                alert.show();

2 个答案:

答案 0 :(得分:0)

android:listSelector="@android:color/transparent"内使用ListView

<ListView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:listSelector="@android:color/transparent"
    android:layout_height="wrap_content">
</ListView>

答案 1 :(得分:0)

这些选择圈是CheckedTextViewView的一部分,simple_list_item_single_choiceListView布局中当前用于Adapter项目布局的TextView布局simple_list_item_1android.R.layout.simple_list_item_single_choice。如果您不想要这些,则可以使用android.R.layout.simple_list_item_1布局为常规ArrayAdapter的布局。

只需在MailRepository rep = new MailRepository("imap.mail.yahoo.com", 993, true, @"xxxxx@yahoo.com", "*******"); foreach (Message email in rep.GetUnreadMails("Inbox")) { //Console.WriteLine(string.Format("<p>{0}: {1}</p><p>{2}</p>", email.From, email.Subject, email.BodyHtml.Text)); Console.WriteLine(email.From); Console.WriteLine(email.Subject); Console.WriteLine(email.BodyHtml.Text); if (email.Attachments.Count > 0) { foreach (MimePart attachment in email.Attachments) { Console.WriteLine(string.Format("<p>Attachment: {0} {1}</p>", attachment.ContentName, attachment.ContentType.MimeType)); } } } 构造函数调用中将printf更改为puts