レイアウト ファイルにリストビューとボタンがあります。そのボタンをクリックすると、リストビューにアイテムを追加したいと思います。アクティビティが開始されたとき、リストビューは空である必要がありますが、アイテムを追加することで拡大する必要があります。「AddItem」ボタンをクリックすると、ユーザーから項目/入力を取得する 1 つの AlertDialog が表示されます。そのアイテムをリストビューに追加するにはどうすればよいですか? コードで私を助けてください。ListView 内で独自のレイアウトを使用するには、どのアダプターを使用すればよいですか? ListActivity を拡張する必要がありますか?
ここに私のレイアウトファイルがあります: my_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue"
android:orientation="vertical" >
<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:divider="@android:color/black"
    android:dividerHeight="2dp" >
</ListView>
<Button
        android:id="@+id/addItemButtom"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_weight="1"
        android:text="Add Item" />
</LinearLayout>
ここに私のrow_item.xmlがあります
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@android:color/white"
 android:orientation="vertical" >
 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:gravity="center"
    android:orientation="horizontal" >
    <TextView  android:layout_weight = "1" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Newly Added Item : "
        android:textColor="@android:color/black"
        android:textSize="17dp" />
    <TextView android:layout_weight = "1" 
        android:id="@+id/itemTextView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
ここに私のJavaファイルがあります:
public class MyList extends Activity implements OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.my_list);
    findViewById(R.id.addItemButtom).setOnClickListener(this);  
}
@Override
public void onClick(View v) 
{
    switch (v.getId()) {
    case R.id.enterInverter:
        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        final EditText et = new EditText(this);      
        et.setHint("Enter Item");
        et.setMaxLines(1);    
        et.setTextSize(17); 
        alert.setTitle("Enter Item");
        alert.setView(et); 
        alert.setInverseBackgroundForced(true);
        alert.setPositiveButton("Add", new DialogInterface.OnClickListener() 
        { 
            public void onClick(DialogInterface dialog, int whichButton) 
            {
                String item = et.getText().toString().trim();
            }
        });
        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
        {
            public void onClick(DialogInterface dialog, int whichButton) 
            {
                dialog.cancel();
            }
        });
        alert.show();
        break;
    default:
        break;
    }
}
}