I have a listview that I want to add event listener to it. The following simple code exits with "Source Not Found" when debugging.
I r开发者_运维百科emembered using exactly the same code for Button object and it did not caused any problem.
mArticleList = (ListView)findViewById(R.id.ArticleList);
populateArticleList();
mArticleList.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
launchFullArticle();
;
}
});
protected void launchFullArticle() {
// TODO Auto-generated method stub
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
If it's a list why you're assigning onClickListener - use onItemClickListener
"Source Not Found" when debugging means you haven't linked the Android source code into Eclipse, and yet you are trying to step into that code. The debugger can't step into it if the source isn't available to it.
You could import the Android source into Eclipse via something like this or you could just step over the Android methods when debugging.
You might miss to provide "layout_height
" and "layout_width
" in your "Layout tag" which may be in main layout or custom layout.
精彩评论