所以我有一个自定义的ListView对象.列表项目有两个堆叠在一起的文本视图,加上一个水平进度条,我想保持隐藏,直到我实际执行某些操作.最右边是一个复选框,我只想在用户需要将更新下载到他们的数据库时显示.当我通过将可见性设置为Visibility.GONE来禁用复选框时,我可以单击列表项.当复选框可见时,除了复选框之外,我无法单击列表中的任何内容.我做了一些搜索,但没有找到任何与我目前的情况相关的东西.我发现了这个问题,但我使用的是重写的ArrayAdapter,因为我正在使用ArrayLists在内部包含数据库列表.我只需要获取LinearLayout视图并像Tom一样添加onClickListener吗?我不确定.
这是listview行布局XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="fill_parent">
<TextView
android:id="@+id/UpdateNameText"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:textSize="18sp"
android:gravity="center_vertical"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:id="@+id/UpdateStatusText"
android:singleLine="true"
android:ellipsize="marquee"
/>
<ProgressBar android:id="@+id/UpdateProgress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminateOnly="false"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:minHeight="10dip"
android:maxHeight="10dip"
/>
</LinearLayout>
<CheckBox android:text=""
android:id="@+id/UpdateCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是扩展ListActivity的类.显然它仍在开发中,所以请原谅那些遗漏或可能留下的东西:
public class UpdateActivity extends ListActivity {
AccountManager lookupDb;
boolean allSelected;
UpdateListAdapter list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lookupDb = new AccountManager(this);
lookupDb.loadUpdates();
setContentView(R.layout.update);
allSelected = false; …
Run Code Online (Sandbox Code Playgroud)