나는 몇 일 동안 저를 따라 다니는이 특별한 문제가 있습니다. 나는 수색을 사용하고 그러나 어떤 기사 마녀도 나의 문제를 위해 도움이 될 것이라는 점을 것을 발견 할 수 없었다. 나는 또한 내 검색의 문제라고 생각한다. 그러나 다시 내 질문에.목록보기에서 위젯을 클릭 할 때 ResourceCursorAdapter를 사용하여보기 항목을 얻는 방법
ResourceCursorAdapter를 사용하여 ListView를 채 웁니다.
내 ListView에 항목이 ...처럼 보이는
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/title_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/description_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<CheckBox
android:id="@+id/download_cb"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/some_bt"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageButton
android:id="@+id/pdf_ib"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ProgressBar
android:id="@+id/download_pb"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="10dip" />
</RelativeLayout>
내 어댑터 : 나는 버튼을 클릭하거나 ListView에있는 체크 박스가 난 일부 내용을 변경하려는 경우
내 질문은 ... 입니다private final class ListAdapter extends ResourceCursorAdapter implements
DownloadCallback, OnItemClickListener, OnClickListener {
public ListAdapter(Context context, int layout, Cursor c) {
super(context, layout, c);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
final ItemHolder holder = (ItemHolder) view.getTag();
holder.url = cursor.getString(..);
holder.titleTv.setText(cursor.getString(..));
holder.descriptionTv.setText(cursor.getString(..));
...
if(cursor.getInt(..) == 1) {
holder.progress.setVisible(View.GONE);
}
if(cursor.getInt(...) == 1) {
holder.downloadCb.setEnabled(isConnectedToNet);
}
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View view = super.newView(context, cursor, parent);
ItemHolder holder = new ItemHolder();
view.setOnClickListener(this);
holder.titleTv = (TextView) view.findViewById(R.id.title_tv);
holder.descriptionTv = (TextView) view.findViewById(R.id.description_tv);
...
holder.downloadCb.setEnabled(isConnectedToNet);
holder.downloadCb.setOnClickListener(this);
holder.downloadCb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prepare2Download();
DownItem di = new DownItem();
di.url = holder.url; /// <========= to do this
// start async downloader and notify progressbar "holder.downPb"
Download serverTaskObject = new Download();
serverTaskObject.execute(currDownholder.copy());
holder.downPb.setVisibility(View.GONE); // <======== and this.
}
});
holder.pdfIb = (ImageButton) view.findViewById(R.id.pdf_ib);
holder.pdfIb.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// start new activity and load website.
openUrl(holder.url); // <============ or this.
}
});
holder.downPb = (ProgressBar) view.findViewById(R.id.pb_law_download);
holder.downPb.setVisibility(View.GONE);
view.setTag(cachedItem);
return view;
}
...
private static class LawItemCache {
TextView titleTv;
TextView descriptionTv;
...
CheckBox downloadCb;
ImageButton pdfIb;
ProgressBar downPb;
String url;
IProgressListener listener;
}
}
특정 View 홀더에서 진행 표시 줄을 보이게하거나 사라지게합니다. 어댑터에서 View holder를 가져 와서 변경하는 방법을 아직 알 수 없습니다.
나는 내 문제와 관련하여 충분히 설명해 주었으면 좋겠다.
죄송합니다. 내가 이미 내 코드를 변경하여 실행할 수있게 될 때까지. 하지만 당신의 대답을 명심하겠습니다. 날 다시 나는이 문제에 빠지게 될 것이다 :) thx !!! – user950117