Android ListActivity에서 ListView에 바닥 글로 버튼을 추가하고 있습니다. 가운데 및/또는 width = fill_parent와 같이이 단추에 레이아웃 서식을 적용하려면 어떻게해야합니까?Android ListActivity에서 레이아웃 서식을 어떻게 바닥 글에 적용합니까?
나는 setLayoutParams()를 사용하는 것과 같은 몇 가지 시도를 해봤지만 작동시키지 못했다. 아무 때나 시도 할 때 항상 바닥 글이 사라진다. 여기
내가 크리스토퍼의 답변에 따라closeButton = new Button(this);
closeButton.setText(getResources().getString(R.string.title_closeprocess));
closeButton.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
closeProcess();
}
});
getListView().addFooterView(closeButton);
* 갱신
함께 일하고 기본 코드입니다, 여기에 내가 내 목록보기에 추가하고 바닥 글보기 및 추가 활동 코드는 목록보기 :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/closebutton_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toptable"
android:layout_width="fill_parent"
android:stretchColumns="*"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content">
<TableRow>
<Button android:id="@+id/closebutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Skip Question"
android:gravity="center"
android:paddingTop="16dip">
</Button>
</TableRow>
</TableLayout>
</RelativeLayout>
ListView listView = getListView();
closeButtonView = getLayoutInflater().inflate(R.layout.closebutton_layout, listView, false);
closeButton = (Button)closeButtonView.findViewById(R.id.closebutton);
closeButton.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
closeQuestion();
}
});
listView.addFooterView(closeButtonView);
감사합니다. 예, 목록과 함께 꼬리말과 스크롤해야합니다 - 나는 항상 부동산을 차지할 수 없습니다. 두 번째 제안은 ...이 바닥 글을 프로그래밍 방식으로 추가해야하므로 LinearLayout에 추가 한 후 그 레이아웃을 바닥 글로 추가하는 방법을 모르겠습니다. 어떻게해야할까요? – JohnRock
죄송합니다. 이전에 무슨 말을하고 있었는지 모르겠습니다. ('View'를 바닥 글로 추가하여 'linearLayout.add (button)'을 할 수는 있지만). 어쨌든 적절한 솔루션으로 게시물을 업데이트했습니다. 좋은 오래된 XML로 바닥 글 레이아웃을 정의한 다음 그것을 팽창시켜 바닥 글에 추가 할 수 있습니다. –
업데이트 해 주셔서 감사합니다. 정확히 내가 놓친 것입니다. 감사. 나는 내 질문을 업데이 트했습니다. 왜냐하면 레이아웃에 임베디드되어 있으므로 이제는 내 꼬리말보기의 Button에 OnClickListener를 할당하는 올바른 구문에 대해 혼란 스럽습니다 ... 제 꼬리말보기를 올바르게 설정 했습니까? – JohnRock