I'm new to android..
I'm facing problem with tittle for listview..
How to implement tittle for list view? help me..
I try like this..
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); viewList = Nexttopic.this.getLayoutInflater().inflate(R.layout.activity_nexttopic, null); dialogMarketList = new Dialog(Nexttopic.this); dialogMarketList.requestWindowFeature(Window.FEATURE_NO_TITLE); dialogMarketList.setTitle("TOPICS"); dialogMarketList.setContentView(viewList); dialogMarketList.show(); lvForDialog = (ListView) viewList.findViewById(R.id.List_view); lvForDialog.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL); ArrayAdapter<String> adapter = (new ArrayAdapter<String>(Nexttopic.this, R.layout.row_topic, R.id.child_row,tnamelist)); lvForDialog.setAdapter(adapter);
Its not working..
try to add
headerView
in yourlistView
, you need to do it before you callsetAdapter()
What docs says /
*Add a fixed view to appear at the top of the list. If addHeaderView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want. NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that will also account for header and footer views.
You are possible want to add a header to listview?
Look add this answer https://stackoverflow.com/a/10730786/1293704
Many tutorials can be found how to add a header.
just remove this:
Edited answer:
use this way:
header.xml
Edited 2nd time:
avoid title go up when scrolling use below code insted of above.
The following command in your code disables the title in the dialog:
If you remove it you should see the dialog with the title.