첫 번째 애플리케이션을 Android에서 제작 중입니다. ActionBarSherlock도 사용하고 있습니다. 지금 개발하고 싶은 것은 radioGroup을 목록 상단 및 하단에 표시하는 대화 상자입니다. ?ListItems의 중심 위치
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent">
<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:checked="true"
android:text="Justified" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Unjustified" />
</RadioGroup>
<customAdapter.MyListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp" >
</customAdapter.MyListView>
: '그렇게 했어,하지만리스트 내 항목이 거기 left.Is에 내가 그들을 중앙에 한 수있는 방법을 위치 시간
이 감사는 XML이다
그리고 이것은 실제 코드입니다 :
,public static class MyDialogFragment extends SherlockDialogFragment {
int mNum;
RadioButton btn1;
RadioButton btn2;
/**
* Create a new instance of MyDialogFragment, providing "num"
* as an argument.
*/
static MyDialogFragment newInstance(int num) {
MyDialogFragment f = new MyDialogFragment();
// Supply num input as an argument.
Bundle args = new Bundle();
args.putInt("num", num);
f.setArguments(args);
return f;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mNum = getArguments().getInt("num");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.myfrg, container, false);
ListView lv = (ListView) v.findViewById(R.id.list);
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item,justifiedAbsences);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
lv.setAdapter(dataAdapter);
return v;
}
}
이는 당신이 텍스트 -와 새에 레이아웃을 변경해야합니다
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
= "센터"당신의 줄에
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity = "center" >
<RadioGroup
android:id="@+id/radiogroup"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:checked="true"
android:text="Justified" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Unjustified" />
</RadioGroup>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp" >
</ListView>
해야 우리는 몇 가지 코드를 가질 수 바랍니다! ? –