Android horizontal navigation menu, android navigation menu
1.:
2. Project address:
Https://github.com/lynnchurch/HorizontalScrollMenu.git
3. Use sample code:
Package com. example. horizontalscrollmenusample; import java. util. arrayList; import java. util. arrays; import java. util. list; import com. lynnchurch. horizontalscrollmenu. baseAdapter; import com. lynnchurch. horizontalscrollmenu. horizontalScrollMenu; import android. app. activity; import android. OS. bundle; import android. view. layoutInflater; import android. view. view; import android. widget. textView; public class MainActivity extends Activity {private HorizontalScrollMenu hsm_container; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); initView ();} public void initView () {hsm_container = (HorizontalScrollMenu) findViewById (R. id. hsm_container); hsm_container.setAdapter (new MenuAdapter ();} class MenuAdapter implements BaseAdapter {String [] names = new String [] {"menu 1", "menu 2 ", "menu 3", "menu 4", "menu 5", "menu 6", "menu 7" };@ Override public List <String> getMenuItems () {// TODO Auto-generated method stub return Arrays. asList (names) ;}@ Override public List <View> getContentViews () {// TODO Auto-generated method stub List <View> views = new ArrayList <View> (); for (String str: names) {View v = LayoutInflater. from (MainActivity. this ). inflate (R. layout. content_view, null); TextView TV = (TextView) v. findViewById (R. id. TV _content); TV. setText (str); views. add (v) ;}return views ;}}}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.