Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
f30b5139
Commit
f30b5139
authored
Jul 14, 2017
by
Mrunzzz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add searchView to actionbar
parent
1bdac8f9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
14 deletions
+48
-14
.idea/misc.xml
.idea/misc.xml
+1
-1
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/PeopleFragment.java
.../in/ac/iitb/gymkhana/iitbapp/fragment/PeopleFragment.java
+30
-7
app/src/main/res/layout/fragment_people.xml
app/src/main/res/layout/fragment_people.xml
+6
-6
app/src/main/res/menu/search_view_menu.xml
app/src/main/res/menu/search_view_menu.xml
+11
-0
No files found.
.idea/misc.xml
View file @
f30b5139
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
</value>
</value>
</option>
</option>
</component>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_7"
default=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_7"
default=
"true"
project-jdk-name=
"1.8
(1)
"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
</component>
<component
name=
"ProjectType"
>
<component
name=
"ProjectType"
>
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/fragment/PeopleFragment.java
View file @
f30b5139
package
in.ac.iitb.gymkhana.iitbapp.fragment
;
package
in.ac.iitb.gymkhana.iitbapp.fragment
;
import
android.app.SearchManager
;
import
android.content.Context
;
import
android.content.Context
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.view.MenuItemCompat
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.MenuInflater
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.ListView
;
import
android.widget.ListView
;
...
@@ -32,6 +37,7 @@ public class PeopleFragment extends Fragment {
...
@@ -32,6 +37,7 @@ public class PeopleFragment extends Fragment {
Bundle
savedInstanceState
)
{
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
// Inflate the layout for this fragment
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_people
,
container
,
false
);
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_people
,
container
,
false
);
setHasOptionsMenu
(
true
);
suggestionList
.
add
(
"Web and Coding Club"
);
suggestionList
.
add
(
"Web and Coding Club"
);
suggestionList
.
add
(
"Electronics and Robotics Club"
);
suggestionList
.
add
(
"Electronics and Robotics Club"
);
...
@@ -59,14 +65,37 @@ public class PeopleFragment extends Fragment {
...
@@ -59,14 +65,37 @@ public class PeopleFragment extends Fragment {
listView
=
(
ListView
)
view
.
findViewById
(
R
.
id
.
list_view
);
listView
=
(
ListView
)
view
.
findViewById
(
R
.
id
.
list_view
);
listView
.
setVisibility
(
View
.
GONE
);
listView
.
setVisibility
(
View
.
GONE
);
searchView
=(
SearchView
)
view
.
findViewById
(
R
.
id
.
search
);
adapter
=
new
PeopleSuggestionAdapter
(
suggestionList
);
adapter
=
new
PeopleSuggestionAdapter
(
suggestionList
);
listView
.
setAdapter
(
adapter
);
listView
.
setAdapter
(
adapter
);
//TODO SuggestionClickListener
return
view
;
}
@Override
public
void
onCreateOptionsMenu
(
Menu
menu
,
MenuInflater
inflater
)
{
super
.
onCreateOptionsMenu
(
menu
,
inflater
);
menu
.
clear
();
inflater
.
inflate
(
R
.
menu
.
search_view_menu
,
menu
);
MenuItem
searchItem
=
menu
.
findItem
(
R
.
id
.
action_search
);
final
SearchManager
searchManager
=
(
SearchManager
)
getContext
().
getSystemService
(
Context
.
SEARCH_SERVICE
);
searchView
=
(
SearchView
)
MenuItemCompat
.
getActionView
(
searchItem
);
searchView
.
setSearchableInfo
(
searchManager
.
getSearchableInfo
(
getActivity
().
getComponentName
()));
searchView
.
setOnQueryTextListener
(
new
SearchView
.
OnQueryTextListener
()
{
searchView
.
setOnQueryTextListener
(
new
SearchView
.
OnQueryTextListener
()
{
@Override
@Override
public
boolean
onQueryTextSubmit
(
String
query
)
{
public
boolean
onQueryTextSubmit
(
String
query
)
{
searchView
.
clearFocus
();
listView
.
setVisibility
(
View
.
GONE
);
listView
.
setVisibility
(
View
.
GONE
);
return
false
;
return
false
;
}
}
...
@@ -80,11 +109,5 @@ public class PeopleFragment extends Fragment {
...
@@ -80,11 +109,5 @@ public class PeopleFragment extends Fragment {
return
false
;
return
false
;
}
}
});
});
//TODO SuggestionClickListener
return
view
;
}
}
}
}
app/src/main/res/layout/fragment_people.xml
View file @
f30b5139
...
@@ -6,12 +6,12 @@
...
@@ -6,12 +6,12 @@
tools:context=
"in.ac.iitb.gymkhana.iitbapp.fragment.PeopleFragment"
>
tools:context=
"in.ac.iitb.gymkhana.iitbapp.fragment.PeopleFragment"
>
<!-- TODO: Update blank fragment layout -->
<!-- TODO: Update blank fragment layout -->
<
android.support.v7.widget.SearchView
<
!--<android.support.v7.widget.SearchView-->
android:id=
"@+id/search"
<!--android:id="@+id/search"-->
android:layout_width=
"match_parent"
<!--android:layout_width="match_parent"-->
android:layout_height=
"wrap_content"
<!--android:layout_height="wrap_content"-->
app:defaultQueryHint=
"Search"
<!--app:defaultQueryHint="Search"-->
android:clickable=
"true"
/
>
<!--android:clickable="true"/>--
>
<ListView
<ListView
android:id=
"@+id/list_view"
android:id=
"@+id/list_view"
...
...
app/src/main/res/menu/search_view_menu.xml
0 → 100644
View file @
f30b5139
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/action_search"
app:actionViewClass=
"android.support.v7.widget.SearchView"
app:showAsAction=
"always|collapseActionView"
android:icon=
"@android:drawable/ic_menu_search"
android:title=
"Search"
/>
</menu>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment