私は、読んだ本のリストと、各エントリのタイトルと作者との一部をアプリケーションにしています。 2つのEditTextボックスと1つのボタンがあります。私はボタンをタップして一緒にリストのエントリに入れて、ボックスからタイトルと作者を取りたいです。私はボックスからデータを受け取り、それぞれ変数に割り当てている部分を持っています。リストに問題があります。相続人は、私がこれまで持っているコード:2つの入力からリストを作成するEditText
package com.lijap.apps.BookTracker;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
public class BooksRead extends ListActivity {
Button addbook;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.booksread);
addbook = (Button) findViewById(R.id.b_addbook);
addbook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//called when you press the button
String bookName =((EditText) findViewById(R.id.et_title)).getText().toString();
String bookAuthor =((EditText) findViewById(R.id.et_author)).getText().toString();
// do the rest of the job
}
});
}
}
ここではリスト関連のコードは表示されませんが、これまでに何をしていますか? –
setContentViewが使用しているxmlファイルにリストビューを作成しましたが、リストと配列アダプタを結合する方法を理解できませんでした。 – Lijap