This is my code, but display the results not right,
/ / Get cursor
database = SQLiteDatabase.openOrCreateDatabase (DBManager.DB_PATH + "/" + DBManager.DB_NAME, null);
Cursor cursorone = database.rawQuery ("select _id, barcode, number from t_firstcheckinfo", null);
if (cursorone.moveToFirst ())
{
/ / Create SimpleCursorAdapter adapter to bind data to item displayed on the control
SimpleCursorAdapter adapter = new SimpleCursorAdapter (this, R.layout.item, cursorone,
new String [] {"barcode", "number",}, new int [] {R.id.barcode, R.id.number});
listView.setAdapter (adapter);
/ / Entry click event
listView.setOnItemClickListener (new ItemClickListener ());
}
}
public class ItemClickListener implements OnItemClickListener {
@ Override
public void onItemClick (AdapterView parent, View view, int position,
long id) {
/ / TODO Auto-generated method stub
ListView listView = (ListView) parent;
Cursor cursor = (Cursor) listView.getItemAtPosition (position);
String personid = String.valueOf (cursor.getInt (cursor.getColumnIndex ("_id")));
Toast.makeText (getApplicationContext (), personid, 1) show ();.
}
}
}
, which displays the number of 15 to go to the bar code below, is not how it happened, Trouble cattle people to see.<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->Reply:
R.layout.item this layout to include two textview to show in a row above.
Reply:
LZ's R.layout.item recommend using LinearLayout layout, set android: orientation = "horizontal", placing the bar code and the number of TextView in the layout inside, adjust the position of the alignment on it.
Reply:
According heroes that put android: orientation = "horizontal" on it, thank you very much Daniel answer. Thank you, thank you.
Reply:
Thank you for your answer.
No comments:
Post a Comment