Hi,I am new to mobile and i am still studying the components,layouts,etc..first i want to know how can i put radiogroup in listview,
i made another xml file "Radiolayout.xml" but i could not display this in listview.
More inputs will be much more appreciated.
This is my java file "Sample01.java"
package com.Android.Sample01;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.ArrayAdapter;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView;
import android.app.*;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
public class Sample01 extends ListActivity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
final String[] str = new String []{"listview1","listview2"};
setListAdapter(new ArrayAdapter<String>(this,R.layout.Mylayout,
str));
ListView lview = getListView();
lview.setTextFilterEnabled(true);
lview.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent,View eview,int position,long id)
{
Toast.makeText(getApplicationContext(), ((TextView)eview).getText(),
Toast.LENGTH_SHORT).show();
}
});
}
}
XML FILE. "Mylayout.xml"
<?xml version="1.0" encoding="UTF-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TextView>
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
Radiolayout.xml
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:baselineAligned="false" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="ButtonOne " />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ButtonTwo " />
</RadioGroup>
</LinearLayout>