试图找出用户单击的书签ID是什么…
什么都试过了,很多力量关闭了…现在是一个空的吐司(Eclipse中没有错误标记):
public class Dmarks extends ListActivity {
protected Context context;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TextView selection;
String[] projection = new String[] {
Browser.BookmarkColumns._ID,
Browser.BookmarkColumns.FAVICON,
Browser.BookmarkColumns.TITLE,
Browser.BookmarkColumns.URL
};
String[] displayFields = new String[] {
Browser.BookmarkColumns.TITLE,
Browser.BookmarkColumns.FAVICON,
Browser.BookmarkColumns.URL
};
final int[] displayViews = new int[] {
android.R.id.text1,
android.R.id.text2
};
Cursor cur = managedQuery(android.provider.Browser.BOOKMARKS_URI, projection, android.provider.Browser.BookmarkColumns.BOOKMARK, null, null);
setListAdapter(new ImageCursorAdapter(this, android.R.layout.simple_list_item_2, cur, displayFields, displayViews));
selection = (TextView)findViewById(R.id.btitle);
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
Context context = getApplicationContext();
TextView text = selection;
int duration = Toast.LENGTH_SHORT;
Toast.makeText(context, (CharSequence) text, duration).show();
}
});
}
ImageCursoradapter是另一个显示书签favicon和标题的类(它起作用)。
真的很感谢你帮我解决我在这里的错误。
谢谢!