这是代码,我认为这不会很难解决,但我已经尽我所能!:
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.row, filenames);
listView1.setAdapter(adapter);
listView1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, final View view,
int position, long id) {
final String item = (String) parent.getItemAtPosition(position);
final File a = new File(extStorageDirectory
+ "/Android/data/com.tobin.swag/backups/" + item);
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(30);
AlertDialog.Builder alertbox = new AlertDialog.Builder(Backups.this);
alertbox.setTitle("Pick a new task for " + item);
alertbox.setCancelable(true);
alertbox.setItems(array, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which){
if (which == 0) {
Toast.makeText(getApplicationContext(), "Uploading to drive is not done, !!>?", Toast.LENGTH_SHORT).show();
}
if (which == 1) {
Toast.makeText(getApplicationContext(), "Copying to there is not done yet, FAR OUT !!>?", Toast.LENGTH_SHORT).show();
}
if (which == 2) {
a.delete();
adapter.notifyDataSetChanged();
listView1.invalidate();
listView1.refreshDrawableState();
}
我要么想删除从列表视图中单击的项目,要么只是在文件已被删除时刷新列表视图!
谢谢您的帮助!