2013年12月4日星期三

Andrews failed to create a dialog program exceptions Ben collapse

Really sorry - what should ask.
probably fail to perform to the red part of the dialog box procedure error and then jumped Sorry restart

button_courseAttendace.setOnClickListener (new OnClickListener () {

@ Override
public void onClick (View arg0) {
/ / TODO Auto-generated method stub
SharedPreferences sharedata = getSharedPreferences ("data", 0);
tid = Integer.parseInt (sharedata.getString ("userID", null));
Pp ("tid" + tid);
RequestParams params = new RequestParams ();
params.put ("tid", tid + "");
params.put ("action", "search_teacherCourse");
client.post (HttpUtil.server_teacher_course, params,
new JsonHttpResponseHandler () {

@ Override
public void onSuccess (int arg0, JSONObject arg1) {
JSONArray object = arg1.optJSONArray ("result");
P.p (object.toString () +1111);

if (object.length () == 0) {
Toast.makeText (WelcomeActivity.this, " Professor any course you have not !", Toast.LENGTH_SHORT) show ().;
} else {

for (int i = 0;. i JSONObject object_temp = arg1.optJSONArray ("result") optJSONObject (i).;
P.p (object_temp.toString () +2222);
list.add (i, (object_temp.optInt ("CId") + "" + (object_temp.optString ("CName"))));
}

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
ListView lv = new ListView (WelcomeActivity.this);
ArrayAdapter a = new ArrayAdapter (WelcomeActivity.this,
R.layout.listview_item_1, list);
lv.setAdapter (a);
LinearLayout listViewLayout = new LinearLayout (WelcomeActivity.this);
listViewLayout.setOrientation (LinearLayout.VERTICAL);
listViewLayout.addView (lv, lp);
final AlertDialog dialog = new AlertDialog.Builder (WelcomeActivity.this)
. setTitle (" Select Course "). setView (listViewLayout) / / here to write this layout load dialog in listview
create ().;

lv.setOnItemClickListener (new AdapterView.OnItemClickListener () {
@ Override
public void onItemClick (AdapterView arg0, View arg1, int arg2, long arg3) {
courseInfo = list.get (arg2);
dialog.dismiss ();
}
});


dialog.show ();
}

super.onSuccess (arg0, arg1);
}
});

}
});


------ Solution ------- -------------------------------------
set a layout_height

没有评论:

发表评论