我想知道如何EditText
使用按钮从ListView
. 我试过这段代码:
public class MainActivity extends Activity {
Button send;
EditText textBox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
send = (Button) findViewById(R.id.sendBtn);
textBox = (EditText) findViewById(R.id.textBox);
EditText text = (EditText) findViewById(R.id.textBox);
String textBox = text.getText().toString();
String arr[] = {};
lv = (ListView) findViewById(R.id.list);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(),
R.layout.activity_main, arr);
lv.setAdapter(adapter);
textBox.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}