I am making an android application that needs to use a ListView
. I want to add a menubutton that says \"Add to list\" and once the user presses that menubutton,
MainActivity.java
com.jtech.listviewapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends AppCompatActivity {
ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (ListView) findViewById(R.id.lv);
String days[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1,days);
listView.setAdapter(arrayAdapter);
}
}