想看到有人能帮助我如何把埃迪特Text箱的内容列入安康岛名单。 我有一个项目Im在这项工作中工作,利用Barcode Scanner扫描条码,并将结果退回EditText箱。
I m now attempting to code the contents of the EditText box with the use of a button to add the contents in the list either within that activity or on another one. I ve looked at the simple note list example and a couple of other examples, however, when I try and implement some of the same concepts, I get no where or I think I get somewhere, but the code does nothing. I m sorry it s late.. been up all night trying to figure this out... Any help, advice, is greatly and always appreciated...
package com.terrellmcqueen.databaseproject474;
import java.util.ArrayList;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
public class Main extends Activity implements OnClickListener {
private static final int REQUEST_BARCODE = 0;
private TextView mBarcodeEdit;
private TextView mScanButton;
// private fields omitted
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mBarcodeEdit = (EditText) findViewById(R.id.myEditText);
mScanButton = (Button) findViewById(R.id.scanButton);
mScanButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.scanButton:
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "SCAN_MODE");
startActivityForResult(intent, REQUEST_BARCODE);
break;
}
}
public void onClick1(View v) {
switch (v.getId()) {
case R.id.btnSimple:
ListView myListView = (ListView) findViewById(R.id.myListView);
final EditText myEditText = (EditText) findViewById(R.id.myEditText);
final ArrayList<String> noteList = new ArrayList<String>();
final ArrayAdapter<String> aa;
// binding an array of Strings
aa = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,noteList);
// here we set the adapter, this turns it on
myListView.setAdapter(aa);
// here is the button
// Button btnSimple = (Button) findViewById(R.id.btnSimple);
// String barcode = mBarcodeEdit.getText().toString();
// String title = mTitleEdit.getText().toString();
// String price = mPriceEdit.getText().toString();
}
}
public void onActivityResult(int requestCode,int resultCode, Intent intent) {
if (requestCode == REQUEST_BARCODE) {
if (resultCode == RESULT_OK) {
String barcode = intent.getStringExtra("SCAN_RESULT");
mBarcodeEdit.setText(barcode);
} else if (resultCode == RESULT_CANCELED) {
finish();
}
}
}
}