クラスTextViews
を介して動的にバインドしているときに、ダイアログで例外が発生しましたBaseAdapter
TextView
ダイアログボックスを取得できますが、値の地獄をバインドしません..
Train_Origin_Destination.java
public void loadAutocomplete1(String strCmdTrain) {
c.moveToFirst();
if (c.isAfterLast() == false) {
do {
listFrom1 = new ArrayList<String>(Arrays.asList(strComments));
listTo1 = new ArrayList<String>(Arrays.asList(strComments));
listFrom1.removeAll(Collections.singleton(null));
HashMap<String, String> map = new HashMap<String, String>();
map.put(KEY_Start, "Hello");
listData.add(map);
Log.e("map", map.toString());
Log.e("list4", listData.toString());
customAdapter = new MyCustomAdapter2(
Train_Origin_Destination.this, listData);
lvTrainTime1.setAdapter(customAdapter);
} while (c.moveToNext());
}
onButtonClick イベント
public void onClick(View arg0) {
Log.d("Dialog", "Dialog");
dialog = new Dialog(context1);
//dialog.setContentView(R.layout.traintimings_dialog);
//dialog.getWindow().getAttributes().windowAnimations = R.style.Animations_SmileWindow;
dialog.setTitle("Train Timings");
//dialog.setContentView(R.id.lvTrainTimings1);
if (chkSunday.isChecked()) {
if (Area_Index < Area_Index1) {
Log.d("Sunday", "Sunday");
} else if (Area_Index > Area_Index1) {
Log.d("SundayReverse", "SundayReverse");
}
} else {
if (Area_Index < Area_Index1) {
Log.d("Normal", "Normal");
if (strSpSelectedItem.contentEquals("Beach - Tambaram")) {
int id = Area_Index + 1;
int id1 = Area_Index1 + 1;
/*
* strCmdTrainFrom =
* "Beach_Thirumalpur_WeekD ays where _id='" + id +
* "' or _id='" + id1 + "'";
*/
strCmdTrainFrom = "Beach_Thirumalpur_WeekDays where _id='"
+ id + "'";
loadAutocomplete1(strCmdTrainFrom);
}
} else if (Area_Index > Area_Index1) {
Log.d("NormalReverse", "NormalReverse");
}
}
Log.d("DialogEndB4", listData.toString());
dialog.show();
Log.d("DialogEnd", "DialogEnd");
}
MyCustomAdapter2.java
public class MyCustomAdapter2 extends BaseAdapter {
private String[] strKeys;
private ArrayList<HashMap<String, String>> alData;
private Context context;
TextView txtBusNo, txtBusVia, txtBusServiceType, txtBusJourneyTime;
TextView[] tvStart;
ListView lvTrainTime1;
View rowView2;
public MyCustomAdapter2(Context context,
ArrayList<HashMap<String, String>> listData) {
super();
Log.d("Custom", "Custom");
this.alData = listData;
this.context = context;
Log.d("alData", alData.toString());
Log.d("Custom1", "Custom1");
}
public int getCount() {
// TODO Auto-generated method stub
Log.d("alData.size()", String.valueOf(alData.size()));
return alData.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Log.d("View", "View");
rowView2 = convertView;
if (rowView2 == null) {
Log.d("View1", "View1");
Train_Origin_Destination trDetails = new Train_Origin_Destination();
// Inflate the layout, list_view.xml, in each row.
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(context.LAYOUT_INFLATER_SERVICE);
Log.d("View2", "View2");
rowView2 = inflater
.inflate(R.layout.textview_autofrom, null, false);
}
txtBusNo = (TextView) rowView2.findViewById(R.id.idTvAutoFrom1);
Log.d("View3", "View3");
HashMap<String, String> hashmap = new HashMap<String, String>();
txtBusNo.setText("Bus No : Hello");
Log.d("View30", "View30");
Log.d("View5", String.valueOf(rowView2));
} else {
}
return rowView2;
}
助けてください..私が間違ったこと:)