Я получаю сообщение об ошибке «Исключение ресурсов не найдено: строковый идентификатор ресурса # 0x5. Я знаю, что это связано с i.putExtra (...). Я пытаюсь извлечь строку из столбца БД gotoURL, чтобы передать строку URL-адреса из listItem в ListView в Activity WebView. Любая помощь PLZ! Thnx!
Я моя активность:
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
// @Override
public void onItemClick(AdapterView<?> a, View v, int position,long id)
{
Object o = lv.getItemAtPosition(position);
Toast.makeText(List_AC.this, "Clicked!", Toast.LENGTH_LONG).show();
Intent i = new Intent(List_AC.this, DocView.class);
Cursor cursor = Adapter_AC.dataCursor;
i.putExtra("url", getString(cursor.getColumnIndexOrThrow("gotoURL")));
startActivity(i);
}
});
Адаптер:
public class Adapter_AC extends SimpleCursorAdapter {
static Cursor dataCursor;
private LayoutInflater mInflater;
public Adapter_AC(Context context, int layout, Cursor dataCursor,
String[] from, int[] to) {
super(context, layout, dataCursor, from, to);
this.dataCursor = dataCursor;
mInflater = LayoutInflater.from(context);
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_item, null);
holder = new ViewHolder();
holder.text1 = (TextView) convertView.findViewById(R.id.label);
holder.text2 = (TextView) convertView.findViewById(R.id.listTitle);
holder.text3 = (TextView) convertView.findViewById(R.id.caption);
holder.text4 = (TextView) convertView.findViewById(R.id.dummy);
holder.text4.setVisibility(View.GONE);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
dataCursor.moveToPosition(position);
int label_index = dataCursor.getColumnIndex("label");
String label = dataCursor.getString(label_index);
int title_index = dataCursor.getColumnIndex("title");
String title = dataCursor.getString(title_index);
int description_index = dataCursor.getColumnIndex("description");
String description = dataCursor.getString(description_index);
int goto_index = dataCursor.getColumnIndex("gotoURL");
String gotoURL = dataCursor.getString(goto_index);
holder.text1.setText(label);
holder.text2.setText(title);
holder.text3.setText(description);
holder.text4.setText(gotoURL);
return convertView;
}
static class ViewHolder {
TextView text1;
TextView text2;
TextView text3;
TextView text4;
protected static final String KEY_TITLE = "text4";
}
}