您的位置:首页 > 移动开发

仿拉手团购App3--周边模块

2017-05-16 00:38 260 查看


fragment_around.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/around_bg_color">

<android.support.v7.widget.Toolbar
android:id="@+id/around_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/around_toolbar_height"
android:background="@color/app_yellow">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/around"
android:textSize="@dimen/textSize_20"
android:textColor="@color/white"/>
</android.support.v7.widget.Toolbar>

<FrameLayout
android:id="@+id/around_titleBar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/around_fl_bg"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/around_titleBar_rl_height"
android:background="@android:color/white"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/around_titleBar_ll_marginLeft"
android:gravity="center_vertical">
<ImageView
android:layout_width="@dimen/around_titleBar_image_width"
android:layout_height="@dimen/around_titleBar_image_height"
android:src="@mipmap/icon_arrow_green"/>
<TextView
android:id="@+id/around_supplier_list_title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/around_titleBar_ll_marginLeft"
android:text="@string/around_all"
android:textColor="@color/around_list_title_color"
android:textSize="@dimen/textSize_18"/>
</LinearLayout>
<ImageView
android:id="@+id/around_supplier_list_cart_iv"
android:layout_width="@dimen/around_titleBar_image_width"
android:layout_height="@dimen/around_titleBar_image_height"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/around_titleBar_cart_marginRight"
android:src="@mipmap/icon_car"/>
</RelativeLayout>
</FrameLayout>

<View
style="@style/around_view_style"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/around_supplier_list_ll_height"
android:gravity="center_vertical"
android:background="@android:color/white"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/around_supplier_list_product"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:id="@+id/around_supplier_list_tv_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/around_supplier_list_all"
android:textSize="@dimen/textSize_14"/>
<ImageView
android:layout_width="@dimen/around_supplier_list_image_width"
android:layout_height="@dimen/around_supplier_list_image_height"
android:src="@mipmap/icon_arrow_down"/>
</LinearLayout>
<LinearLayout
android:id="@+id/around_supplier_list_sort"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:id="@+id/around_supplier_list_tv_sort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/around_supplier_list_sort"
android:textSize="@dimen/textSize_14"/>
<ImageView
android:layout_width="@dimen/around_supplier_list_image_width"
android:layout_height="@dimen/around_supplier_list_image_height"
android:src="@mipmap/icon_arrow_down"/>
</LinearLayout>
<LinearLayout
android:id="@+id/around_supplier_list_activity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:id="@+id/around_supplier_list_tv_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/around_supplier_list_activity"
android:textSize="@dimen/textSize_14"/>
<ImageView
android:layout_width="@dimen/around_supplier_list_image_width"
android:layout_height="@dimen/around_supplier_list_image_height"
android:src="@mipmap/icon_arrow_down"/>
</LinearLayout>
</LinearLayout>

<View
style="@style/around_view_style"/>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/around_listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/around_list_marginTop"
style="@style/around_list_view_style"
android:divider="@color/around_list_divider_color"
android:dividerHeight="@dimen/around_list_divider_height"/>
</RelativeLayout>

</LinearLayout>


AroundFragment:

PopupWindow弹出三个选择项

private void initPopMenu() {
View popView = LayoutInflater.from(getActivity()).inflate(R.layout.layout_popwin_supplier_list, null);
mPopListView = (ListView) popView.findViewById(R.id.popwin_list_view);
mPopupWindow = new PopupWindow(popView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
mPopupWindow.setOutsideTouchable(true);
mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
mPopupWindow.setFocusable(true);
mPopupWindow.setAnimationStyle(R.style.popwin_anim_style);
mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
mSupplierListTvProduct.setTextColor(getResources().getColor(R.color.around_supplier_title_color));
mSupplierListTvSort.setTextColor(getResources().getColor(R.color.around_supplier_title_color));
mSupplierListTvActivity.setTextColor(getResources().getColor(R.color.around_supplier_title_color));
}
});

popView.findViewById(R.id.popwin_bottom).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mPopupWindow.dismiss();
}
});

mMenuAdapter1 = new SimpleAdapter(getActivity(), mMenuData1, R.layout.item_popwin_list,
new String[]{"name"}, new int[]{R.id.item_popwin_tv});
mMenuAdapter2 = new SimpleAdapter(getActivity(), mMenuData2, R.layout.item_popwin_list,
new String[]{"name"}, new int[]{R.id.item_popwin_tv});
mMenuAdapter3 = new SimpleAdapter(getActivity(), mMenuData3, R.layout.item_popwin_list,
new String[]{"name"}, new int[]{R.id.item_popwin_tv});
mPopListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
switch (supplierMenuIndex) {
case 0:
mSupplierListTvProduct.setText(mMenuData1.get(i).get(MENU_DATA_KEY));
mPopupWindow.dismiss();
break;
case 1:
mSupplierListTvSort.setText(mMenuData2.get(i).get(MENU_DATA_KEY));
mPopupWindow.dismiss();
break;
case 2:
mSupplierListTvActivity.setText(mMenuData3.get(i).get(MENU_DATA_KEY));
mPopupWindow.dismiss();
break;
default:
break;
}
}
});
}

@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.around_supplier_list_product:
mSupplierListTvProduct.setTextColor(getResources().getColor(R.color.around_supplier_title_selected_color));
mPopListView.setAdapter(mMenuAdapter1);
mPopupWindow.showAsDropDown(mSupplierListProduct, 0, 2);
supplierMenuIndex = 0;
break;
case R.id.around_supplier_list_sort:
mSupplierListTvSort.setTextColor(getResources().getColor(R.color.around_supplier_title_selected_color));
mPopListView.setAdapter(mMenuAdapter2);
mPopupWindow.showAsDropDown(mSupplierListSort, 0, 2);
supplierMenuIndex = 1;
break;
case R.id.around_supplier_list_activity:
mSupplierListTvActivity.setTextColor(getResources().getColor(R.color.around_supplier_title_selected_color));
mPopListView.setAdapter(mMenuAdapter3);
mPopupWindow.showAsDropDown(mSupplierListActivity, 0, 2);
supplierMenuIndex = 2;
break;
default:
break;
}
}


layout_popwin_supplier_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/popwin_bg_color">

<ListView
android:id="@+id/popwin_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/around_list_view_style"
android:divider="#0000"
android:dividerHeight="0dp"/>

<LinearLayout
android:id="@+id/popwin_bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"/>

</LinearLayout>


item_popwin_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:background="@color/white"
android:paddingLeft="@dimen/item_popowin_paddingLR"
android:paddingRight="@dimen/item_popowin_paddingLR"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/item_popwin_tv"
android:layout_width="match_parent"
android:layout_height="@dimen/item_popowin_tv_height"
android:gravity="center_vertical"
tools:text="地点"
android:textColor="@color/around_supplier_title_color"
android:textSize="@dimen/textSize_14"/>

<View
style="@style/around_view_style"/>

</LinearLayout>


  

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: