Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding action bar in ListActivity

I'm very newbie in Android. I need some help and your suggestion here.
I'm work in Android starting last january, I have a some trouble here. I'm still working on app for Android 2.3. Very very simple app. I've read about the action bar, and I've suggest to the library such as greendroid, sherlock actionbar and the last Johan Nilson actionbar. I'm still have difficulties to integrate it into my app. So I try to create my own action bar and the trouble came one by one. One of: it's hard to combine the action bar with my ListView to still stay on the top of screen even the list view scroll down. At last the layout of action bar generate into header of ListView:

View header = getLayoutInflater().inflate(R.layout.header, null);
ListView listView = getListView();
listView.addHeaderView(header);

and the button & imagebutton not working for click event..

//try action button in actionbar
Menu1 = (Button) this.findViewById(id.button1);
Menu1.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View v)
    {
        Toast.makeText(List_direktoriJson.this, "action bar..", Toast.LENGTH_LONG).show();          
    }
});

How the way, if I want the action bar still on top in list view layout? And why the button and imagebutton not working when clicking?

like image 630
rage Avatar asked Nov 05 '22 05:11

rage


1 Answers

If you can manage to include one of the Action Bar libraries such as Sherlock, it will be much simpler :

    private class YourListActivity extends SherlockListActivity {

}
like image 148
kmb64 Avatar answered Nov 09 '22 05:11

kmb64