Back to project page octodroid.
The source code is released under:
MIT License
If you think the Android project octodroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.octodroid.activities; // ww w . j a v a2 s. c o m import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.SearchView; import android.text.TextUtils; import android.view.Menu; import android.view.MenuItem; import com.example.octodroid.R; import com.example.octodroid.adapters.SearchResultAdapter; import butterknife.ButterKnife; import butterknife.InjectView; public class SearchResultActivity extends ActionBarActivity { @InjectView(R.id.repository_list) RecyclerView searchResultListView; private SearchResultAdapter searchResultAdapter; private SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { if (!TextUtils.isEmpty(query)) { searchResultAdapter.submit(query); } return false; } @Override public boolean onQueryTextChange(String newText) { return false; } }; public static void launch(Context context) { Intent intent = new Intent(context, SearchResultActivity.class); context.startActivity(intent); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search_result); ButterKnife.inject(this); setupActionBar(); setupViews(); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_search_result, menu); MenuItem menuItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) menuItem.getActionView(); searchView.setIconifiedByDefault(true); searchView.setSubmitButtonEnabled(false); searchView.setQueryHint(getString(R.string.repositories)); searchView.setOnQueryTextListener(onQueryTextListener); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onBackPressed(); return true; case R.id.action_search: return true; default: return super.onOptionsItemSelected(item); } } private void setupActionBar() { ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowHomeEnabled(true); } private void setupViews() { searchResultAdapter = new SearchResultAdapter(searchResultListView); searchResultListView.setAdapter(searchResultAdapter); } }