از ورودی دریافت و در listView خروجی دهد

برنامه بنویسید که پس از دریافت ورودی از EditText انرا بازدن یک دکمه به listView انتقال دهد.در اندرویدکد xml :<RelativeLayout xmlns:android=&quothttp://schemas.android.com/apk/res/android&quot xmlns:app=&quothttp://schemas.android.com/apk/res-auto&quot xmlns:tools=&quothttp://schemas.android.com/tools&quot android:layout_width=&quotmatch_parent&quot android:layout_height=&quotmatch_parent&quot tools:context=&quotcom.example.amir.test6.MainActivity&quot> <TextView android:layout_width=&quotwrap_content&quot android:layout_height=&quotwrap_content&quot android:text=&quotHello User!&quot android:textSize=&quot30dp&quot android:background=&quot#af1&quot app:layout_constraintBottom_toBottomOf=&quotparent&quot app:layout_constraintLeft_toLeftOf=&quotparent&quot app:layout_constraintRight_toRightOf=&quotparent&quot app:layout_constraintTop_toTopOf=&quotparent&quot app:layout_constraintHorizontal_bias=&quot0.802&quot app:layout_constraintVertical_bias=&quot0.054&quot android:id=&quot@+id/textView&quot android:layout_marginEnd=&quot76dp&quot android:layout_alignParentTop=&quottrue&quot android:layout_alignParentEnd=&quottrue&quot /> <ListView android:layout_width=&quot138dp&quot android:layout_height=&quot495dp&quot tools:layout_editor_absoluteX=&quot8dp&quot tools:layout_editor_absoluteY=&quot8dp&quot android:id=&quot@+id/listview&quot android:background=&quot#8ad&quot android:layout_alignTop=&quot@+id/additem&quot android:layout_alignParentStart=&quottrue&quot android:layout_marginTop=&quot25dp&quot /> <EditText android:id=&quot@+id/editText&quot android:layout_width=&quotwrap_content&quot android:layout_height=&quotwrap_content&quot android:layout_marginTop=&quot23dp&quot android:ems=&quot10&quot android:inputType=&quottextPersonName&quot android:hint=&quotPlease Enter Your Text&quot android:background=&quot#dd5&quot android:layout_below=&quot@+id/textView&quot android:layout_alignParentEnd=&quottrue&quot android:layout_marginEnd=&quot37dp&quot /> <Button android:id=&quot@+id/additem&quot android:layout_width=&quotwrap_content&quot android:layout_height=&quotwrap_content&quot android:text=&quotlist add&quot android:hint=&quotPlease Enter Your Text&quot android:background=&quot#f8f&quot android:=&quot&quot android:layout_marginTop=&quot24dp&quot android:layout_below=&quot@+id/editText&quot android:layout_toEndOf=&quot@+id/listview&quot /> </RelativeLayout>کد activity :public class MainActivity extends AppCompatActivity { EditText editText; Button addButton; ListView listView; ArrayList<String> listItems; ArrayAdapter<String> adapter; String []str ={&quottehran&quot,&quotesfahan&quot,&quotshiraz&quot,&quotsistan&quot,&quotkerman&quot,&quotkhorasan&quot}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); editText = (EditText) findViewById(R.id.editText); addButton = (Button) findViewById(R.id.additem); listView = (ListView) findViewById(R.id.listview); listItems = new ArrayList<String>(); listItems.add(&quottehran&quot); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems); listView.setAdapter(adapter); addButton.setListener(new View.Listener() { public void (View v) { listItems.add(editText.getText().toString()); adapter.notifyDataSetChanged(); } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { Toast.makeText(MainActivity.this, &quotClicked&quot, Toast.LENGTH_LONG).show(); } }); } }