我有一个listview包含项目和页脚视图。项目布局可以正常工作,但页脚的布局不像项目视图那样工作......
我无法理解我的错在哪里。
这是我的项目布局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"
android:gravity="center"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/lstCardItem"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@drawable/pm_dashboard_cardshadow" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5.33dp"
android:layout_marginLeft="11.67dp"
android:layout_marginRight="11.67dp"
android:layout_marginTop="6dp" >
<ImageView
android:id="@+id/ivCard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:animateLayoutChanges="true"
android:scaleType="fitXY" />
<com.controls.DynamicResizeImageView
android:id="@+id/ivCardLock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@drawable/pm_dashboard_cardmask"
android:scaleType="center"
android:src="@drawable/selector_btn_dashboard_lock" />
<LinearLayout
android:id="@+id/llInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:gravity="top|right"
android:orientation="vertical"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:visibility="visible" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center|right"
android:gravity="center|right"
android:orientation="horizontal"
android:paddingBottom="4dp"
android:paddingTop="4dp" >
<TextView
android:id="@+id/tvCardBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/tvCurrency"
android:gravity="top"
android:text="10,344"
android:textColor="@color/white"
android:textSize="18dp"
android:typeface="serif" />
<TextView
android:id="@+id/tvCurrency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="3dp"
android:layout_marginTop="2dp"
android:gravity="top"
android:text="@string/global_currency"
android:textColor="@color/white"
android:textSize="10dp"
android:typeface="sans" />
<TextView
android:id="@+id/tvCardBalanceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="@string/pgDashboard_lblBalanceBanner"
android:textColor="@color/white"
android:textSize="11.33dp"
android:typeface="monospace" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/pm_dashboard_seam" />
</LinearLayout>
对于我的业务方面生命周期:
private void refreshCards() {
if (applyButtons != null)
DashboardFragment.this.lvCards.removeFooterView(applyButtons);
applyButtons = new LinearLayout(getActivity());
applyButtons.setTag("FOOTER");
applyButtons.setOrientation(LinearLayout.VERTICAL);
AbsListView.LayoutParams LLParams = new AbsListView.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
applyButtons.setLayoutParams(LLParams);
if (ininalCount < 32) {
View createNewCardButton = getApplyButtonView(R.string.pgDashboard_lblCreateIninalCard, R.drawable.pm_dashboard_card_yenikartolustur, R.drawable.pm_dashboard_arrow_icon, new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), CreateNewCardActivity.class);
startActivity(intent);
}
});
View AddCard = getApplyButtonView(R.string.pgDashboard_lblAddCard, R.drawable.pm_dashboard_card_yenikartekle, R.drawable.pm_dashboard_plus_icon, new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), AddCardActivity.class);
startActivity(intent);
}
});
applyButtons.addView(createNewCardButton);
applyButtons.addView(AddCard);
}
final View applyIngCard = getApplyButtonView(R.string.pgDashboard_lblApplyToIngCard, R.drawable.pm_dashboard_card_orange, R.drawable.pm_dashboard_arrow_icon, new View.OnClickListener() {
@Override
public void onClick(View v) {
CardApplicationActivity.Synchronizer.synchronize((BaseActivity) getActivity(), new OnSyncCompletedListener() {
@Override
public void onSyncCompleted() {
Intent intent = new Intent(getActivity(), CardApplicationActivity.class);
startActivity(intent);
}
});
}
});
applyButtons.addView(applyIngCard);
View view = new View(getActivity());
view.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics())));
view.setBackgroundResource(getResources().getColor(R.color.transparent));
applyButtons.addView(view);
bindAdapter();
}
private View getApplyButtonView(int stringId, int backgroundId, int iconId, View.OnClickListener onClickListener) {
final View view = inflater.inflate(R.layout.dashboard_list_card_item, null);
return view;
}
public void bindAdapter() {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
DashboardFragment.this.lvCards.setLayoutTransition(new LayoutTransition());
DashboardFragment.this.lvCards.addFooterView(applyButtons, null, false);
if (adapter == null) {
adapter = new CardListAdapter(getActivity(), R.layout.dashboard_list_card_item, productModelContainerList);
controller = new CardListController(lvCards);
lvCards.setDropListener(this);
controller.setDragInitMode(CardListController.ON_LONG_PRESS);
lvCards.setFloatViewManager(controller);
lvCards.setOnTouchListener(controller);
lvCards.setAdapter(adapter);
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
DashboardFragment.this.lvCards.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
DashboardFragment.this.lvCards.setLayoutTransition(null);
}
}
答案 0 :(得分:0)
在这里我做了一些更改,使用这些并让我知道...否则我需要你的可绘制资源来设置它。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/lstCardItem"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@color/background_holo_dark" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5.33dp"
android:layout_marginLeft="11.67dp"
android:layout_marginRight="11.67dp"
android:layout_marginTop="6dp" >
<ImageView
android:id="@+id/ivCard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:animateLayoutChanges="true"
android:scaleType="fitXY" />
<ImageView
android:id="@+id/ivCardLock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@color/background_holo_light"
android:scaleType="center"
android:src="@color/bgColor" />
<LinearLayout
android:id="@+id/llInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/cropBG"
android:gravity="top|right"
android:orientation="vertical"
android:paddingLeft="18dp"
android:paddingRight="18dp"
android:visibility="visible" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right|center_horizontal"
android:gravity="center|right"
android:orientation="horizontal"
android:paddingBottom="4dp"
android:paddingTop="4dp" >
<TextView
android:id="@+id/tvCardBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/tvCurrency"
android:gravity="top"
android:text="10,344"
android:textColor="@android:color/white"
android:textSize="18dp"
android:typeface="serif" />
<TextView
android:id="@+id/tvCurrency"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="3dp"
android:layout_marginTop="2dp"
android:gravity="top"
android:text="Currency"
android:textColor="@android:color/white"
android:textSize="10dp"
android:typeface="sans" />
<TextView
android:id="@+id/tvCardBalanceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="pgDashboard_lblBalanceBanner"
android:textColor="@android:color/white"
android:textSize="11.33dp"
android:typeface="monospace" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bottom_btn_bg_color" />
</LinearLayout>