android - how to settittle to listview in infater layout? -


i'm new android..

i'm facing problem tittle listview..

how implement tittle list view? me..

i try 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..

just remove this:

dialogmarketlist.requestwindowfeature(window.feature_no_title); 

edited answer:

enter image description here

use way:

layoutinflater inflater = (layoutinflater) getsystemservice(context.layout_inflater_service);         viewlist = getlayoutinflater().inflate(r.layout.activity_main_, null);         dialogmarketlist = new dialog(mainactivity.this);         dialogmarketlist.requestwindowfeature(window.feature_no_title);         dialogmarketlist.settitle("topics");         dialogmarketlist.setcontentview(viewlist);         dialogmarketlist.show();         listview lvfordialog = (listview) viewlist.findviewbyid(r.id.listview1);          header = inflater.inflate(r.layout.header, null);          lvfordialog.addheaderview(header);         lvfordialog.settranscriptmode(listview.transcript_mode_always_scroll);         arrayadapter<string> adapter = (new arrayadapter<string>(                 mainactivity.this, android.r.layout.simple_list_item_1, a));         lvfordialog.setadapter(adapter); 

header.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:gravity="center"     android:orientation="horizontal" >      <imageview         android:id="@+id/imageview1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/ic_launcher" />      <textview         android:id="@+id/textview1"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:gravity="center"         android:text="my title"         android:textappearance="?android:attr/textappearancelarge" /> 


edited 2nd time:

avoid title go when scrolling use below code insted of above.

alertdialog.builder builder = new alertdialog.builder(mainactivity.this);         builder.settitle("my title");         builder.seticon(getresources().getdrawable(r.drawable.ic_launcher));          builder.setadapter(new arrayadapter<string>(mainactivity.this,                 r.layout.row, r.id.child_row, items),                 new dialoginterface.onclicklistener() {                      @override                     public void onclick(dialoginterface dialog, int which) {                         // todo auto-generated method stub                       }                 });          builder.show(); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -