同じページに異なるデータを読み込んでいます。私はそれを持っているので、それは私のアイテムをリストしていて、私が1つをクリックすると、それは正しい次のページタイプとIDを送信します。しかし、それはまだ私の最初のページのSQLStatementをロードしています。正しいものがログアウトされています。
最初にそれを片付ける必要がありますか?
これが私のコードです:
public class LocationListView extends Activity {
String SQLStatement;
String itemID = "1001-0001021";
String Type;
;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_location_list_view);
Bundle extras = getIntent().getExtras();
String dataType;
String dataID;
if (extras != null) {
dataType = extras.getString("Type");
dataID = extras.getString("ID");
} else {
dataType = "notset";
dataID = "notset";
}
File dbfile = new File(Global.currentDBfull);
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
if(dataType == "notset") {
SQLStatement = "select * from stationobjects where stationid= " + Global.StationID + " and objectid=0";
Type = "Room";
} else if(dataType == "Room") {
SQLStatement = "select * from stationobjects where stationid= " + Global.StationID + " and objectid=1001 and diagramid like '"+ itemID +"%'";
Type = "Area";
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
} else if(dataType == "Area") {
Type = "Zone";
} else if(dataType == "Zone") {
} else {
SQLStatement = "select * from stationobjects where stationid= " + Global.StationID + " and objectid=0";
Type = "Room";
}
Cursor c = db.rawQuery(SQLStatement, null);
if(c.getCount() != 0) {
Log.e("LocationListView", "Found Items");
c.moveToFirst();
ArrayList<String> mItemName = new ArrayList<String>();
final ArrayList<String> mItemID = new ArrayList<String>();
c.moveToFirst();
while(!c.isAfterLast()) {
mItemName.add(c.getString(c.getColumnIndex("Name")));
mItemID.add(c.getString(c.getColumnIndex("StationObjectID")));
c.moveToNext();
}
final ListView listView = (ListView) findViewById(R.id.lvLocation);
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, mItemName);
int[] colors = {0, 0xFFFF0000, 0};
listView.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
listView.setDividerHeight(1);
listView.setAdapter(adapter);
listView.setClickable(true);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
Object o = listView.getItemAtPosition(position);
String StationObjectID = mItemID.get(position);
Log.e("LocationListView", "" + o);
Log.e("LocationListView", "" + StationObjectID);
startActivityForResult(SwapPage, 0);
}
});
} else {
Log.e("LocationListView", "Not Found Items");
Context context = getApplicationContext();
CharSequence text = "Sorry No data returned";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
db.close();
}
}