Commit 17bbf4fe563a57a07d1f5cba7acf5c17e9a403a9
1 parent
88ca7a04
- add imeoption search and enter button listener
Showing
7 changed files
with
35 additions
and
27 deletions
app/src/main/AndroidManifest.xml
... | ... | @@ -26,8 +26,7 @@ |
26 | 26 | <activity android:name=".IndexActivitiy"/> |
27 | 27 | <activity android:name=".ActivityLogin" |
28 | 28 | android:label="LOGIN" |
29 | - android:theme="@style/AppTheme.NoActionBar" /> | |
30 | - | |
29 | + android:theme="@style/AppTheme.UserstoryNoActionBar" /> | |
31 | 30 | </application> |
32 | 31 | |
33 | 32 | </manifest> | ... | ... |
app/src/main/java/net/devfac/userstory/FragmentAddBook.java
... | ... | @@ -3,14 +3,17 @@ package net.devfac.userstory; |
3 | 3 | import android.os.Bundle; |
4 | 4 | import android.support.annotation.Nullable; |
5 | 5 | import android.support.v4.app.Fragment; |
6 | +import android.view.KeyEvent; | |
6 | 7 | import android.view.LayoutInflater; |
7 | 8 | import android.view.View; |
8 | 9 | import android.view.ViewGroup; |
10 | +import android.view.inputmethod.EditorInfo; | |
9 | 11 | import android.webkit.WebView; |
10 | 12 | import android.widget.AdapterView; |
11 | 13 | import android.widget.Button; |
12 | 14 | import android.widget.EditText; |
13 | 15 | import android.widget.ListView; |
16 | +import android.widget.TextView; | |
14 | 17 | import android.widget.Toast; |
15 | 18 | |
16 | 19 | import net.devfac.userstory.FSM.Action; |
... | ... | @@ -25,9 +28,8 @@ import static net.devfac.userstory.FSM.state.StateBookSearchToAdd.*; |
25 | 28 | /** |
26 | 29 | * Created by Onether on 15. 10. 30.. |
27 | 30 | */ |
28 | -public class FragmentAddBook extends Fragment implements View.OnClickListener, StateEventListener { | |
31 | +public class FragmentAddBook extends Fragment implements StateEventListener { | |
29 | 32 | private ListView mListSearchedResult; |
30 | - private Button mBtnSearchToAdd; | |
31 | 33 | private EditText mEditBookTitleToAdd; |
32 | 34 | private ArrayAdapterBookSearchResult mArrayAdapterBookSearchResult; |
33 | 35 | |
... | ... | @@ -39,36 +41,40 @@ public class FragmentAddBook extends Fragment implements View.OnClickListener, S |
39 | 41 | View v = inflater.inflate(R.layout.fragment_addbook, container, false); |
40 | 42 | |
41 | 43 | mListSearchedResult = (ListView)v.findViewById(R.id.list_searched_result); |
42 | - mBtnSearchToAdd = (Button)v.findViewById(R.id.btn_search_to_add); | |
43 | 44 | mEditBookTitleToAdd = (EditText)v.findViewById(R.id.edit_book_title_to_add); |
44 | 45 | |
45 | - mBtnSearchToAdd.setOnClickListener(this); | |
46 | 46 | mListSearchedResult.setOnItemLongClickListener(new SearchResultLongClickListener()); |
47 | 47 | |
48 | 48 | webView = (WebView)v.findViewById(R.id.webView2); |
49 | 49 | |
50 | 50 | StateContext.getInstance(getActivity()).setStateEventListener(this); |
51 | 51 | |
52 | - return v; | |
53 | - } | |
54 | - | |
55 | - @Override | |
56 | - public void onClick(View v) { | |
57 | - switch (v.getId()){ | |
58 | - case R.id.btn_search_to_add: | |
59 | - String keyword = mEditBookTitleToAdd.getText().toString(); | |
60 | - | |
61 | -// new ProcessSearchBookTask(getActivity()).execute(keyword, null, null); | |
62 | - SearchBookReq searchBookReq = new SearchBookReq(); | |
63 | - searchBookReq.keyword = keyword; | |
52 | + mEditBookTitleToAdd.setOnEditorActionListener(new TextView.OnEditorActionListener() { | |
53 | + @Override | |
54 | + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { | |
55 | + if( actionId == EditorInfo.IME_ACTION_SEARCH){ | |
56 | + String keyword = v.getText().toString(); | |
64 | 57 | |
58 | + SearchBookReq searchBookReq = new SearchBookReq(); | |
59 | + searchBookReq.keyword = keyword; | |
65 | 60 | // WebView wv = (WebView)getActivity().findViewById(R.id.webView2); |
66 | 61 | // StateContext.getInstance(getActivity()).setWebView(wv); |
67 | 62 | |
68 | - StateContext.getInstance(getActivity()).processEvent(Action.REQ_BOOK_SEARCH_TO_ADD, searchBookReq); | |
63 | + StateContext.getInstance(getActivity()).processEvent(Action.REQ_BOOK_SEARCH_TO_ADD, searchBookReq); | |
64 | + } | |
65 | + else if( event.getKeyCode() == KeyEvent.KEYCODE_ENTER){ | |
66 | + String keyword = v.getText().toString(); | |
69 | 67 | |
70 | - break; | |
71 | - } | |
68 | + SearchBookReq searchBookReq = new SearchBookReq(); | |
69 | + searchBookReq.keyword = keyword; | |
70 | + | |
71 | + StateContext.getInstance(getActivity()).processEvent(Action.REQ_BOOK_SEARCH_TO_ADD, searchBookReq); | |
72 | + } | |
73 | + return false; | |
74 | + } | |
75 | + }); | |
76 | + | |
77 | + return v; | |
72 | 78 | } |
73 | 79 | |
74 | 80 | @Override | ... | ... |
app/src/main/java/net/devfac/userstory/MainActivity.java
... | ... | @@ -110,6 +110,8 @@ public class MainActivity extends AppCompatActivity |
110 | 110 | |
111 | 111 | mTabLayoutMain = (TabLayout)findViewById(R.id.tablayout_main); |
112 | 112 | mTabLayoutMain.setupWithViewPager(mViewPagerMain); |
113 | + mTabLayoutMain.getTabAt(mViewPagerAdapter.getPosition(Constants.FRAGMENT_TITLE_BOOK_SHELF)).setIcon(R.drawable.icon_book_shelf); | |
114 | + mTabLayoutMain.getTabAt(mViewPagerAdapter.getPosition(Constants.FRAGMENT_TITLE_ADD_BOOK)).setIcon(R.drawable.icon_add_book); | |
113 | 115 | |
114 | 116 | mAppBarMain = (AppBarLayout)findViewById(R.id.appBarLayoutMain); |
115 | 117 | mCoordinateMain = (CoordinatorLayout)findViewById(R.id.coordinator_main); | ... | ... |
app/src/main/res/drawable/icon_book_shelf.png
0 → 100644
3.55 KB
app/src/main/res/drawable/icon_magifying_glass.png
0 → 100644
3.3 KB
app/src/main/res/layout/fragment_addbook.xml
... | ... | @@ -9,17 +9,14 @@ |
9 | 9 | android:layout_height="wrap_content"> |
10 | 10 | |
11 | 11 | <EditText |
12 | + android:drawableLeft="@drawable/icon_magifying_glass" | |
12 | 13 | android:layout_width="wrap_content" |
13 | 14 | android:layout_height="wrap_content" |
14 | 15 | android:id="@+id/edit_book_title_to_add" |
16 | + android:imeOptions="actionSearch" | |
17 | + android:singleLine="true" | |
15 | 18 | android:layout_weight="1" /> |
16 | 19 | |
17 | - <Button | |
18 | - style="?android:attr/buttonStyleSmall" | |
19 | - android:layout_width="wrap_content" | |
20 | - android:layout_height="wrap_content" | |
21 | - android:text="SEARCH" | |
22 | - android:id="@+id/btn_search_to_add" /> | |
23 | 20 | </LinearLayout> |
24 | 21 | |
25 | 22 | <ListView | ... | ... |
app/src/main/res/values/styles.xml
... | ... | @@ -11,6 +11,10 @@ |
11 | 11 | <item name="windowActionBar">false</item> |
12 | 12 | <item name="windowNoTitle">true</item> |
13 | 13 | </style> |
14 | + <style name="AppTheme.UserstoryNoActionBar"> | |
15 | + <item name="windowActionBar">false</item> | |
16 | + <item name="windowNoTitle">true</item> | |
17 | + </style> | |
14 | 18 | <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> |
15 | 19 | <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> |
16 | 20 | ... | ... |