Git Product home page Git Product logo

android_tabview's Introduction

android_tabView

like ios UITabView,you can add your item;

your can use it easy.

tabView = (TabView) findViewById(R.id.tabview); List list = new ArrayList(); list.add("关于我们"); list.add("意见反馈"); list.add("应用推荐"); list.add("清除缓存"); list.add("版本更新"); tabView.setAdapter(new MyTabAdapter(this, list)); tabView.setOnItemClickListener(new TabItemClickListener() {

	@Override
	public void onClick(int position, View v) {
		// TODO Auto-generated method stub
		switch (position) {
		case 0:
			Toast.makeText(MainActivity.this, "关于我们_item" + position, 0)
					.show();
				break;
			case 1:
				Toast.makeText(MainActivity.this, "意见反馈_item" + position, 0)
						.show();
				break;
			case 2:
				Toast.makeText(MainActivity.this, "应用推荐_item" + position, 0)
						.show();
				break;
			case 3:
				Toast.makeText(MainActivity.this, "清除缓存_item" + position, 0)
						.show();
				break;
			case 4:
				Toast.makeText(MainActivity.this, "版本更新_item" + position, 0)
						.show();
				break;
			}
		}
	});

2.use adapter mode

class MyTabAdapter extends TabAdapter {

	Context context;
	List<String> list;

	public MyTabAdapter(Context context, List<String> list) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public View getView(int position) {
		// TODO Auto-generated method stub
		View view = LayoutInflater.from(context).inflate(R.layout.item,
				null);
		TextView tv = (TextView) view.findViewById(R.id.tv);
		tv.setText(list.get(position));
		return view;
	}

}

android_tabview's People

Contributors

allen1988 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.