try {
//ปลายทาง
mCursor = mDb.rawQuery("select bus.name,bus.id_bus, place.name_place, bus.picture from bus left join place_bus on place_bus.id_bus = bus.id_bus left join place on place_bus.id_place = place.id_place where name_place =" + "\"" + message + "\"", null);//" + "\"" + message + "\""
final ArrayList<String> dirArray = new ArrayList<String>();
final ArrayList<String> dirArray3 = new ArrayList<String>();
mCursor.moveToFirst();
while (mCursor.isAfterLast() == false) {
dirArray.add("ee " + mCursor.getString(mCursor.getColumnIndex(MyDatabase.COL_NAMEB)));
dirArray3.add(mCursor.getString(mCursor.getColumnIndex(MyDatabase.COL_ID_BUS)));
mCursor.moveToNext();
}
if (dirArray.size()==0) {
Toast.makeText(context, "ไม่มีข้อมูลในฐานข้อมูล", Toast.LENGTH_SHORT).show();
textView.setText("****"+dirArray);
}
final ArrayAdapter<String> adapterDir = new ArrayAdapter<String>(getApplicationContext()
, android.R.layout.simple_list_item_1, dirArray);
listView1.setAdapter(adapterDir);
listView1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent newActivity = new Intent(getApplicationContext(), Detil_say1.class);
newActivity.putExtra("ID_BUS", dirArray3.get(position));
startActivity(newActivity);
}
});
//select bus.name, place.name_place from bus left join place_bus on place_bus.id_bus = bus.id_bus left join place on place_bus.id_place = place.id_place where
// name_place =
//check ต้นทาง
mCursor1 = mDb.rawQuery("select bus.name, place.name_place from bus left join place_bus on place_bus.id_bus = bus.id_bus left join place on place_bus.id_place = place.id_place where name_place = " + "\"" + Name + "\"", null);
final ArrayList<String> dirArray1 = new ArrayList<String>();
final ArrayList<String> dirArray2 = new ArrayList<String>();//id ไปหน้า map เพื่อเปิดแผนที่
mCursor1.moveToFirst();
while (mCursor1.isAfterLast() == false) {
dirArray1.add("ww" + mCursor1.getString(mCursor1.getColumnIndex(MyDatabase.COL_NAMEB)));
dirArray2.add(mCursor1.getString(mCursor1.getColumnIndex(MyDatabase.COL_ID_BUS)));
mCursor1.moveToNext();
}
if (dirArray1.size() == 0) {
Toast.makeText(context, "ไม่มีข้อมูลในฐานข้อมูล", Toast.LENGTH_SHORT).show();
textView.setText("ต้นทาง");
}
final ArrayAdapter<String> adapterDir1 = new ArrayAdapter<String>(getApplicationContext()
, android.R.layout.simple_list_item_1, dirArray1);
listView2.setAdapter(adapterDir1);
listView2.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent newActivity = new Intent(getApplicationContext(), Detil_say2.class);
newActivity.putExtra("id_bus", dirArray2.get(position));
startActivity(newActivity);
}
});
} catch (Exception e) {
//Toast.makeText(context, "No Data", Toast.LENGTH_SHORT).show();
}