我正在努力让我的listview使用多个选择功能。我已经按照了几个教程并提出了以下代码。出于某种原因,我不能让CAB显示出来,我想知道我在这里做错了什么。
这是我尝试将listview设置为多选的功能以及我尝试给CAB充气的功能
RewriteEngine on
RewriteBase /
RewriteRule ^([\w-]+)/(?!includes/pages/)(.+)$ $1/includes/pages/$2 [L,NC]
这是我的listview项目布局
public void loadGroupSchedule(final int gid) {
SUBLEVEL = 1;
CustomListViewValuesArrSchedules.clear();
// list.notify();
list = (ListView) findViewById(R.id.listViewCustom);
list.setAdapter(null);
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
list.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
}
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuInflater inflater = mode.getMenuInflater();
inflater.inflate(R.menu.test, menu);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
}
});
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest sr = new StringRequest(Request.Method.POST, SERVER_SCHEDULES, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
... //too much code, deleted it from here
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (SUBLEVEL != 5) {
hideLoading();
list.setVisibility(View.INVISIBLE);
ISVU.setVisibility(View.INVISIBLE);
noInternet.setVisibility(View.VISIBLE);
Button retry = (Button) findViewById(R.id.noInternetBtn);
retry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
noInternet.setVisibility(View.INVISIBLE);
list.setVisibility(View.VISIBLE);
loadGroupSchedule(gid);
}
});
}
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("groupid", String.valueOf(gid));
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
//params.put("Content-Type", "application/x-www-form-urlencoded");
return new HashMap<String, String>();
}
};
showLoading();
queue.add(sr);
}
这是我的列表视图
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="80dp"
android:id="@+id/classItemLV"
android:background="@drawable/list_row"
android:minHeight="80dp"
android:elevation="2dp">
<RelativeLayout
android:layout_width="16dp"
android:layout_height="wrap_content"
android:id="@+id/lday"
android:layout_alignParentStart="true"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"
android:background="@color/colorPrimary"
android:minWidth="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="P\nO\nN"
android:id="@+id/DAY1"
android:layout_alignParentStart="false"
android:textColor="#fff"
android:textSize="15sp"
android:layout_margin="2dp"
android:textAlignment="center"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lTime"
android:layout_alignWithParentIfMissing="false"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/lday">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="10"
android:id="@+id/timeFrom"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:textColor="@color/colorLV3Dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="12"
android:id="@+id/timeTo"
android:textColor="@color/colorLV3Dark"
android:layout_below="@+id/timeFrom" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lInfo"
android:layout_marginStart="10dp"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/lTime">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Analiza financijskih izvještaja"
android:id="@+id/className"
android:textColor="@color/colorLV3Dark"
android:layout_alignParentStart="true"
android:layout_marginEnd="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="prof. dr. sc. Ivan Ivić"
android:id="@+id/classTutor"
android:textColor="@color/colorLV3"
android:layout_below="@+id/className" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="PREDAVANJE - DV41"
android:id="@+id/classTypePlace"
android:textColor="@color/colorLV3"
android:textSize="12sp"
android:layout_below="@+id/classTutor" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Datum: 5.10.-25.1."
android:id="@+id/classDate"
android:textSize="12sp"
android:textColor="@color/colorLV3"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@+id/classTypePlace"
android:layout_marginEnd="10dp" />
</RelativeLayout>
</RelativeLayout>
这是我的菜单
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listViewCustom"
android:dividerHeight="0dp" />
我正在为listview使用自定义适配器,这可能是个问题吗?任何帮助将不胜感激。