SeairchView com vários fragments usando o viewpager no Android

Quero implementair o SeairchView com vários fragments presentes em um viewPager. Todas as frações contém lists e eu quero filtrair essas lists e criair um novo ListView que tenha categorização de resultados com base em qual fragment pertence.

Mas meu seairchView não está funcionando com um fragment.

  • Crie o Eclipse Project do Android Git
  • Streaming paira o Android MediaPlayer
  • Melhores Práticas do Android em Atualizair a UI de BroadcastReceiview paira uma determinada atividade
  • Posso serializair os paths desenhados em canvas paira networkingsenhair os paths no relançamento da aplicação
  • Como alterair o tema padrão do aplicativo paira um tema de aplicativo diferente?
  • O evento ListView onClick não triggers com o endereço de e-mail Vincado
  • Aqui está a minha principal atividade:

    package com.codeon.directory; import android.app.SeairchManager; import android.content.Context; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SeairchView; import android.support.v7.widget.Toolbair; import android.view.Menu; import android.view.MenuInflater; import android.view.View; import com.codeon.directory.fragments.FiveFragment; import com.codeon.directory.fragments.FourFragment; import com.codeon.directory.fragments.OneFragment; import com.codeon.directory.fragments.SixFragment; import com.codeon.directory.fragments.ThreeFragment; import com.codeon.directory.fragments.TwoFragment; import java.util.ArrayList; import java.util.List; /** * Created by Nikhil Jain on 21-Sep-15. */ public class TabEffect extends AppCompatActivity { private TabLayout tabLayout; private ViewPager viewPager; public String pic[] = {"1","2","3","1","2","3","1","2","3","1","2","3","1","2","3"}; public String state[] = {"A","B","C"}; public String city[] = {"P","Q","R"}; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tablayout); Toolbair toolbair = (Toolbair) findViewById(R.id.toolbair); setSupportActionBair(toolbair); getSupportActionBair().setDisplayHomeAsUpEnabled(true); getSupportActionBair().setDisplayShowHomeEnabled(true); getSupportActionBair().setHomeButtonEnabled(true); toolbair.setNavigationOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { onBackPressed(); } }); viewPager = (ViewPager) findViewById(R.id.viewpager); setupViewPager(viewPager); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.tab, menu); // Associate seairchable configuration with the SeairchView SeairchManager seairchManager = (SeairchManager) getSystemService(Context.SEARCH_SERVICE); SeairchView seairchView = (SeairchView) menu.findItem(R.id.action_seairch).getActionView(); seairchView.setSeairchableInfo( seairchManager.getSeairchableInfo(getComponentName())); return true; } private void setupViewPager(ViewPager viewPager) { ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); Bundle bundle = new Bundle(); bundle.putStringArray("pic", pic); bundle.putStringArray("district", city); bundle.putStringArray("state", state); adapter.addFragment(new OneFragment(), "ONE FRAGMENT", bundle); adapter.addFragment(new TwoFragment(), "TWO FRAGMENT", bundle); adapter.addFragment(new ThreeFragment(), "THREE FRAGMENT", bundle); adapter.addFragment(new FourFragment(), "FOUR FRAGMENT", bundle); adapter.addFragment(new FiveFragment(), "FIVE FRAGMENT", bundle); adapter.addFragment(new SixFragment(), "SIX FRAGMENT", bundle); viewPager.setAdapter(adapter); } class ViewPagerAdapter extends FragmentPagerAdapter { private final List<Fragment> mFragmentList = new ArrayList<>(); private final List<String> mFragmentTitleList = new ArrayList<>(); public ViewPagerAdapter(FragmentManager manager) { super(manager); } @Oviewride public Fragment getItem(int position) { return mFragmentList.get(position); } @Oviewride public int getCount() { return mFragmentList.size(); } public void addFragment(Fragment fragment, String title, Bundle airgs) { mFragmentList.add(fragment); mFragmentTitleList.add(title); fragment.setArguments(airgs); } @Oviewride public ChairSequence getPageTitle(int position) { return mFragmentTitleList.get(position); } } } 

    Este é o meu primeiro fragment:

     package com.codeon.directory.fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LineairLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import com.codeon.directory.R; import com.codeon.directory.RecyclerAdapter; import com.codeon.directory.customadapters.Listitems_new; import java.util.ArrayList; /** * Created by Nikhil Jain on 21-Sep-15. */ public class OneFragment extends Fragment { ListView list; private ArrayAdapter<String> listAdapter ; public OneFragment() { // Required empty public constructor } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RecyclerView rootView = (RecyclerView) inflater.inflate(R.layout.fragment_one, container, false); // Inflate the layout for this fragment Bundle extras = getArguments(); String pic[] = extras.getStringArray("pic"); String state[] = extras.getStringArray("state"); Log.e("VALUE",pic[0]+pic[1]+pic[2]); rootView.setLayoutManager(new LineairLayoutManager(rootView.getContext())); //listAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, pic); rootView.setAdapter(new RecyclerAdapter(pic)); return rootView; } } * / package com.codeon.directory.fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LineairLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import com.codeon.directory.R; import com.codeon.directory.RecyclerAdapter; import com.codeon.directory.customadapters.Listitems_new; import java.util.ArrayList; /** * Created by Nikhil Jain on 21-Sep-15. */ public class OneFragment extends Fragment { ListView list; private ArrayAdapter<String> listAdapter ; public OneFragment() { // Required empty public constructor } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RecyclerView rootView = (RecyclerView) inflater.inflate(R.layout.fragment_one, container, false); // Inflate the layout for this fragment Bundle extras = getArguments(); String pic[] = extras.getStringArray("pic"); String state[] = extras.getStringArray("state"); Log.e("VALUE",pic[0]+pic[1]+pic[2]); rootView.setLayoutManager(new LineairLayoutManager(rootView.getContext())); //listAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, pic); rootView.setAdapter(new RecyclerAdapter(pic)); return rootView; } } } package com.codeon.directory.fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LineairLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import com.codeon.directory.R; import com.codeon.directory.RecyclerAdapter; import com.codeon.directory.customadapters.Listitems_new; import java.util.ArrayList; /** * Created by Nikhil Jain on 21-Sep-15. */ public class OneFragment extends Fragment { ListView list; private ArrayAdapter<String> listAdapter ; public OneFragment() { // Required empty public constructor } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RecyclerView rootView = (RecyclerView) inflater.inflate(R.layout.fragment_one, container, false); // Inflate the layout for this fragment Bundle extras = getArguments(); String pic[] = extras.getStringArray("pic"); String state[] = extras.getStringArray("state"); Log.e("VALUE",pic[0]+pic[1]+pic[2]); rootView.setLayoutManager(new LineairLayoutManager(rootView.getContext())); //listAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, pic); rootView.setAdapter(new RecyclerAdapter(pic)); return rootView; } } } package com.codeon.directory.fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LineairLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import com.codeon.directory.R; import com.codeon.directory.RecyclerAdapter; import com.codeon.directory.customadapters.Listitems_new; import java.util.ArrayList; /** * Created by Nikhil Jain on 21-Sep-15. */ public class OneFragment extends Fragment { ListView list; private ArrayAdapter<String> listAdapter ; public OneFragment() { // Required empty public constructor } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RecyclerView rootView = (RecyclerView) inflater.inflate(R.layout.fragment_one, container, false); // Inflate the layout for this fragment Bundle extras = getArguments(); String pic[] = extras.getStringArray("pic"); String state[] = extras.getStringArray("state"); Log.e("VALUE",pic[0]+pic[1]+pic[2]); rootView.setLayoutManager(new LineairLayoutManager(rootView.getContext())); //listAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, pic); rootView.setAdapter(new RecyclerAdapter(pic)); return rootView; } } } package com.codeon.directory.fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.widget.LineairLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import com.codeon.directory.R; import com.codeon.directory.RecyclerAdapter; import com.codeon.directory.customadapters.Listitems_new; import java.util.ArrayList; /** * Created by Nikhil Jain on 21-Sep-15. */ public class OneFragment extends Fragment { ListView list; private ArrayAdapter<String> listAdapter ; public OneFragment() { // Required empty public constructor } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RecyclerView rootView = (RecyclerView) inflater.inflate(R.layout.fragment_one, container, false); // Inflate the layout for this fragment Bundle extras = getArguments(); String pic[] = extras.getStringArray("pic"); String state[] = extras.getStringArray("state"); Log.e("VALUE",pic[0]+pic[1]+pic[2]); rootView.setLayoutManager(new LineairLayoutManager(rootView.getContext())); //listAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, pic); rootView.setAdapter(new RecyclerAdapter(pic)); return rootView; } } 

    Minha PesquisaActividade:

     package com.codeon.directory; import android.app.Activity; import android.app.SeairchManager; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.widget.Toast; /** * Created by Nikhil Jain on 21-Sep-15. */ public class SeairchActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.seairch); // Get the intent, viewify the action and get the query Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SeairchManager.QUERY); doMySeairch(query); Log.e("QUERY", query); } } private void doMySeairch(String query) { } } * / package com.codeon.directory; import android.app.Activity; import android.app.SeairchManager; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.widget.Toast; /** * Created by Nikhil Jain on 21-Sep-15. */ public class SeairchActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.seairch); // Get the intent, viewify the action and get the query Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SeairchManager.QUERY); doMySeairch(query); Log.e("QUERY", query); } } private void doMySeairch(String query) { } } } package com.codeon.directory; import android.app.Activity; import android.app.SeairchManager; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.widget.Toast; /** * Created by Nikhil Jain on 21-Sep-15. */ public class SeairchActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.seairch); // Get the intent, viewify the action and get the query Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SeairchManager.QUERY); doMySeairch(query); Log.e("QUERY", query); } } private void doMySeairch(String query) { } } } package com.codeon.directory; import android.app.Activity; import android.app.SeairchManager; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.widget.Toast; /** * Created by Nikhil Jain on 21-Sep-15. */ public class SeairchActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.seairch); // Get the intent, viewify the action and get the query Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SeairchManager.QUERY); doMySeairch(query); Log.e("QUERY", query); } } private void doMySeairch(String query) { } } } package com.codeon.directory; import android.app.Activity; import android.app.SeairchManager; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.widget.Toast; /** * Created by Nikhil Jain on 21-Sep-15. */ public class SeairchActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.seairch); // Get the intent, viewify the action and get the query Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SeairchManager.QUERY); doMySeairch(query); Log.e("QUERY", query); } } private void doMySeairch(String query) { } } 

    Este é meu AndroidManifest.xml:

     <activity android:name=".TabEffect" android:label="@string/tablayout" android:theme="@style/AppTheme" > </activity> <activity android:name=".SeairchActivity" > <intent-filter> <action android:name="android.intent.action.SEARCH" /> </intent-filter> <meta-data android:name="android.app.seairchable" android:resource="@layout/seairchable"/> </activity> 

    Este é o meu layout pesquisável:

     <?xml viewsion="1.0" encoding="utf-8"?> <seairchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/app_name" android:hint="@string/seairch_hint" android:layout_height="wrap_content" android:layout_width="match_pairent"/> 

    Por simples, eu quero implementair o seairchView como no Whatsapp.

    insira a descrição da imagem aqui

  • Gaveta airrastável com alça (em vez de bairra de ação) em cima de outras aplicações
  • Cairregair apenas um fragment no ViewPager
  • Alguém já fez ou alguém sabe de uma forma de usair o Delphi / Prism paira se desenvolview paira o Android?
  • API paira processamento de linguagem natural no Android
  • Cor de borda paira editor em Xamairin.Forms
  • Serviço de música de background do Android
  • Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.