At the moment I'm interested in developing my own android app.
Therefore I wanted to work with a ListView.
Actually my test-application crashes right after the start. I hope you can help me with it.
MainActivity.java
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String[] liste = {"Adidas","Nike","Puma"};
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,liste);
ListView list=(ListView)findViewById(R.id.list);
list.setAdapter(adapter);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="de.phxlxp_mxyxr.listview.MainActivity">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal" />
</android.support.constraint.ConstraintLayout>