Got error of app when click on list item
When i click on list item im get error and closing app. how to fix it? where im wrong. im need to show text WTF in custom dialog window
customdialoglayout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/layout_root"
          android:orientation="vertical"
          android:background="@drawable/kmp"              
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">
<TextView android:id="@+id/dialog_title"        
    android:textColor="#FFF"
    android:textSize="16sp"
    android:layout_width="fill_parent" android:gravity="center"  android:layout_height="30dp" android:layout_marginTop="5dp"/>
<TextView android:id="@+id/dialog_text"     
    android:textColor="#FFF"
    android:layout_height="35dp" android:layout_width="fill_parent"  android:gravity="center"/>
in mainActivity
    @Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    String toastMessage = messages.get(position).toString();
    Builder customdialoglayout = new AlertDialog.Builder(this)
    .setCancelable(true)
    .setIcon(R.drawable.icon);
    TextView text = (TextView) findViewById(R.id.dialog_text);
    text.setText("WTF");
    setContentView(R.layout.customdialoglayout);    
}
fixed problem already by:
    Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.customdialoglayout);
    dialog.setTitle(rssTitle);
    dialog.setCancelable(true);
    TextView text = (TextView开发者_如何学C) dialog.findViewById(R.id.dialog_text);
    text.setText("WTF");
    dialog.show();
You have to use the  .Builder 
here a reference to Android dev Guide!
    AlertDialog.Builder yourDialog =  new AlertDialog.Builder(this);
    yourDialog .setTitle(rssTitle);
    dialog.show();
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论