0
任何人都可以幫助我的代碼,我正在開發一個android應用程序,需要一些幫助。在一個叫做結果的屏幕上,我需要在視圖中的sqlite數據庫中顯示記錄的標題,必須單擊該標題並打開一個新窗口以顯示完整記錄。長按必須允許用戶刪除該記錄。顯示標題點擊並移動到下一個屏幕android
這是我走到這一步:
import java.util.ArrayList;
public class Main extends Activity {
ListView txtMainList;
// EditText nameTxt,posTxt;
Button saveBtn,retrieveBtn,btnBegin;
ArrayList<String >accidents=new ArrayList<String>();
EditText index;
ArrayAdapter<String> Adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
index=(EditText)findViewById(R.id.txtRegistrationNo);
btnBegin = (Button) findViewById(R.id.btnBegin);
txtMainList = (ListView) findViewById(R.id.txtMainList);
Adapter = new ArrayAdapter<String>(this, android.R.layout.simple_selectable_list_item, accidents);
final DBHelper newDb=new DBHelper(this);
accidents.clear();
Cursor c=newDb.getYVAllData();
while (c.moveToNext())
{
accidents.add("Accident Number : "+c.getString(0));
}
txtMainList.setAdapter(Adapter);
newDb.close();
txtMainList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View agr1, int index, long id) {
Toast.makeText(getApplicationContext(), accidents.get(index), Toast.LENGTH_SHORT).show();
}
});
}
請分享你到目前爲止做了什麼。 – Nitesh
我已經添加了我的代碼。 –