d
This commit is contained in:
@@ -24,6 +24,7 @@ import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.zaaach.citypicker.adapter.CityListAdapter;
|
||||
@@ -123,6 +124,17 @@ public class CityPickerDialogFragment extends DialogFragment implements TextWatc
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
RelativeLayout rl_back = mContentView.findViewById(R.id.rl_back);
|
||||
rl_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
if (mOnPickListener != null){
|
||||
mOnPickListener.onCancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
TextView tv_title = mContentView.findViewById(R.id.tv_title);
|
||||
mRecyclerView = mContentView.findViewById(R.id.cp_city_recyclerview);
|
||||
mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
@@ -159,10 +171,10 @@ public class CityPickerDialogFragment extends DialogFragment implements TextWatc
|
||||
mSearchBox = mContentView.findViewById(R.id.cp_search_box);
|
||||
mSearchBox.addTextChangedListener(this);
|
||||
|
||||
mCancelBtn = mContentView.findViewById(R.id.cp_cancel);
|
||||
mClearAllBtn = mContentView.findViewById(R.id.cp_clear_all);
|
||||
mCancelBtn.setOnClickListener(this);
|
||||
mClearAllBtn.setOnClickListener(this);
|
||||
// mCancelBtn = mContentView.findViewById(R.id.cp_cancel);
|
||||
// mClearAllBtn = mContentView.findViewById(R.id.cp_clear_all);
|
||||
// mCancelBtn.setOnClickListener(this);
|
||||
// mClearAllBtn.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
@@ -251,13 +263,13 @@ public class CityPickerDialogFragment extends DialogFragment implements TextWatc
|
||||
public void afterTextChanged(Editable s) {
|
||||
String keyword = s.toString();
|
||||
if (TextUtils.isEmpty(keyword)){
|
||||
mClearAllBtn.setVisibility(View.GONE);
|
||||
// mClearAllBtn.setVisibility(View.GONE);
|
||||
mEmptyView.setVisibility(View.GONE);
|
||||
mResults = mAllCities;
|
||||
((SectionItemDecoration)(mRecyclerView.getItemDecorationAt(0))).setData(mResults);
|
||||
mAdapter.updateData(mResults);
|
||||
}else {
|
||||
mClearAllBtn.setVisibility(View.VISIBLE);
|
||||
// mClearAllBtn.setVisibility(View.VISIBLE);
|
||||
//开始数据库查找
|
||||
mResults = dbManager.searchCity(keyword);
|
||||
((SectionItemDecoration)(mRecyclerView.getItemDecorationAt(0))).setData(mResults);
|
||||
@@ -274,14 +286,14 @@ public class CityPickerDialogFragment extends DialogFragment implements TextWatc
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.cp_cancel) {
|
||||
dismiss();
|
||||
if (mOnPickListener != null){
|
||||
mOnPickListener.onCancel();
|
||||
}
|
||||
}else if(id == R.id.cp_clear_all){
|
||||
mSearchBox.setText("");
|
||||
}
|
||||
// if (id == R.id.cp_cancel) {
|
||||
// //dismiss();
|
||||
// if (mOnPickListener != null){
|
||||
// mOnPickListener.onCancel();
|
||||
// }
|
||||
// }else if(id == R.id.cp_clear_all){
|
||||
// mSearchBox.setText("");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
BIN
citypicker/src/main/res/drawable/icon_back.png
Normal file
BIN
citypicker/src/main/res/drawable/icon_back.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
6
citypicker/src/main/res/drawable/shape_sousuo_bg.xml
Normal file
6
citypicker/src/main/res/drawable/shape_sousuo_bg.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape android:shape="rectangle"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#fff6f6f6" />
|
||||
<corners android:topLeftRadius="18dp" android:topRightRadius="18dp" android:bottomLeftRadius="18dp" android:bottomRightRadius="18dp" />
|
||||
</shape>
|
||||
@@ -3,7 +3,53 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:background="#ffffff"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_back"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:background="@drawable/icon_back"
|
||||
android:textColor="#000000" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="城市选择"
|
||||
android:textColor="#000000"
|
||||
android:textSize="17sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/right"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:textColor="#ff333333"
|
||||
android:textSize="14sp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone"
|
||||
android:layout_marginRight="13dp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
<include layout="@layout/cp_search_view" />
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
@@ -1,55 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/cp_search_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="60dp"
|
||||
android:background="@android:color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="16dp"
|
||||
|
||||
tools:showIn="@layout/cp_dialog_city_picker">
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/cp_search_box"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:hint="?attr/cpSearchHintText"
|
||||
android:maxLength="20"
|
||||
android:maxLines="1"
|
||||
android:textCursorDrawable="?attr/cpSearchCursorDrawable"
|
||||
android:textColor="?attr/cpSearchTextColor"
|
||||
android:textColorHint="?attr/cpSearchHintTextColor"
|
||||
android:textSize="?attr/cpSearchTextSize" />
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginLeft="22.5dp"
|
||||
android:layout_marginRight="22.5dp"
|
||||
android:gravity="center"
|
||||
android:layout_height="37dp"
|
||||
android:background="@drawable/shape_sousuo_bg"
|
||||
android:hint="搜索城市名"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#ff999999"
|
||||
android:imeActionLabel="搜索"
|
||||
android:imeOptions="actionSend"
|
||||
android:inputType="text"
|
||||
android:singleLine="true"
|
||||
android:text="" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cp_clear_all"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="2dp"
|
||||
android:visibility="gone"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="?attr/cpClearTextIcon" />
|
||||
|
||||
<Space
|
||||
android:layout_width="6dp"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<View
|
||||
android:layout_width="1px"
|
||||
android:layout_height="14dp"
|
||||
android:background="@color/cp_color_gray_light"/>
|
||||
|
||||
<Space
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cp_cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cp_cancel"
|
||||
android:textColor="?attr/cpCancelTextColor"
|
||||
android:textSize="?attr/cpCancelTextSize" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
Reference in New Issue
Block a user