我有一个这样的网页数据库:
import android.provider.BaseColumns;
public interface ThreadDatabase extends BaseColumns {
String TABLE_NAME = "Threads";
String TITLE = "Title";
String DESCRIPTION = "Description";
String URL = "Url";
String[] COLUMNS = new String[] { _ID, TITLE, DESCRIPTION, URL };
}
我的 Activity 中的 Listview 带有一个 SimpleCursorAdapter,它在每一行中显示 Title 和 Descripton。
Cursor c = dbhelper.getDatabase();
setListAdapter(new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2, c, new String[] {
ThreadDatabase.TITLE, ThreadDatabase.DESCRIPTION },
new int[] { android.R.id.text1, android.R.id.text2, })
如何重新定义 onListItemClick 方法,以便在单击项目时打开正确的 url?
protected void onListItemClick(ListView l, View v, int position, long id) {
???Missing part???
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}