Skip to content

Commit 928e8a1

Browse files
committed
修改 UI
1 parent 825ee5a commit 928e8a1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

app/src/main/java/net/coding/program/search/SearchProjectActivity.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.widget.TextView;
2020

2121
import net.coding.program.R;
22+
import net.coding.program.common.Global;
2223
import net.coding.program.common.SearchProjectCache;
2324
import net.coding.program.common.adapter.SearchHistoryListAdapter;
2425
import net.coding.program.common.ui.BackActivity;
@@ -71,6 +72,7 @@ void init() {
7172
btnCancel = actionBar.findViewById(R.id.btnCancel);
7273
btnCancel.setOnClickListener(v -> {
7374
editText.setText("");
75+
Global.popSoftkeyboard(this, editText, true);
7476
});
7577

7678
editText = (EditText) actionBar.findViewById(R.id.editText);
@@ -249,17 +251,19 @@ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
249251

250252
@Override
251253
public void onTextChanged(CharSequence s, int start, int before, int count) {
252-
253254
}
254255

255256
@Override
256257
public void afterTextChanged(Editable s) {
257-
if (s == null || TextUtils.isEmpty(s)) {
258+
if (TextUtils.isEmpty(s)) {
258259
emptyListView.setVisibility(View.VISIBLE);
259260
pager.setVisibility(View.GONE);
260261
tabs.setVisibility(View.GONE);
261262
mSearchData = "";
262263
loadSearchCache();
264+
btnCancel.setVisibility(View.INVISIBLE);
265+
} else {
266+
btnCancel.setVisibility(View.VISIBLE);
263267
}
264268
}
265269
}

app/src/main/res/layout/activity_search_project_actionbar.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
android:layout_height="55dp"
44
android:background="@color/color_primary"
55
android:gravity="center_vertical"
6-
76
android:orientation="horizontal">
87

98
<EditText
@@ -41,8 +40,9 @@
4140

4241
<ImageView
4342
android:id="@+id/btnCancel"
44-
android:layout_width="96dp"
45-
android:layout_height="96dp"
43+
android:layout_width="48dp"
44+
android:layout_height="48dp"
45+
android:visibility="invisible"
4646
android:layout_alignParentRight="true"
4747
android:layout_centerVertical="true"
4848
android:src="@drawable/ic_actionbar_cancel"

0 commit comments

Comments
 (0)