Im Trying To paste data(from an Intent) on a customized ListView ,and then I get this error,but when I did it with an uncustomized ListView it worked properly. I understood that the problem occurs when I change :
ListAdapter theAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,timegone);
to:
ListAdapter theAdapter=new ArrayAdapter<String>(this,R.layout.row_layout,timegone);
But I dont get why it doesnt work!
Here below I added the row_layout.xml file which Causes the app crash.
Thats how it works :
public class Shifts extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shifts);
Intent MyIntent=getIntent();
String timepass=MyIntent.getExtras().getString("time");
ListView thelist=(ListView)findViewById(R.id.MyListView);
String[] timegone=timepass.split(":");
ListAdapter theAdapter=new ArrayAdapter<String>(this,**android.R.layout.simple_list_item_1**,timegone);
thelist.setAdapter(theAdapter);
}
}
And thats how it doesnt work:
public class Shifts extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shifts);
Intent MyIntent=getIntent();
String timepass=MyIntent.getExtras().getString("time");
ListView thelist=(ListView)findViewById(R.id.MyListView);
String[] timegone=timepass.split(":");
ListAdapter theAdapter=new ArrayAdapter<String>(this,**R.layout.row_layout**,timegone);
thelist.setAdapter(theAdapter);
}
}
This is the row_layout.xml that im using in the adapter
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainScreen"
android:id="@+id/ly"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv1"
android:textSize="30sp"
android:textStyle="bold"
android:padding="15dp"/>
</LinearLayout>
What should I do in order to fix this ? Thank you!
@android:id/text1. Or remove the LinearLayout, because it's useless, it has just one child element.