I have a string-array, that i need to display in a layout.
The code currently shows the list, but the list isn’t in the layout, its make a new “screen” where the only thing you can see is the list.
Here’s the code that i just can’t get to show the list in the layouts listview.
import android.app.ListActivity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.ArrayAdapter;
public class idchart extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.idchart);
Resources res = getResources();
// To get the string array associated with particular resource ID.
String[] ids = res.getStringArray(R.array.idchart_array);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.test_list_item,ids);
setListAdapter(adapter);
}
}
layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_main"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/logo" />
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<RelativeLayout
android:id="@+id/relative"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ListView
android:id="@+id/lv"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</RelativeLayout>
</LinearLayout>
I haven’t been able to find anything that helped 🙁 so i hope you will be able to.
And you can avoid extending ListActivity.
If you are using ListActivity then