点击不适用于inflateview小部件

时间:2014-01-31 13:03:04

标签: android view onclick layout-inflater

在我的活动中,我正在给布局充气,我正在点击按钮并布局它不起作用。

MyActivity inflating代码:

 LayoutInflater langListInflate = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
     View booksListView = new View(BookActivity.this);
    booksListView =            langListInflate.inflate(getResources().getLayout(R.layout.more_books_items),
            null);
    Button b = (Button) booksListView.findViewById(R.id.likes_button);

    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            System.out.println("Rating bar click");
            Intent intent = new Intent(BookActivity.this,
                    RatingActivity.class);
            startActivity(intent);
        }
    });

0 个答案:

没有答案