欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

Android TabSwitcher自定義控件

系統 2027 0
??? 先來看下效果:
Android TabSwitcher自定義控件

main.xml
    <?xml version="1.0" encoding="utf-8"?><linearlayout xmlns:android="http://schemas.android.com/apk/res/android"	android:orientation="vertical" android:layout_width="fill_parent"	android:layout_height="fill_parent" android:background="#ffffff">	<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"		android:id="@+id/tab" android:orientation="vertical"		android:layout_width="fill_parent" android:layout_height="wrap_content"		android:background="#ffffff">	</linearlayout></linearlayout>
  


tabswitcher.java
    package com.iaiai.activity;import android.content.context;import android.graphics.color;import android.view.gravity;import android.view.view;import android.widget.linearlayout;import android.widget.textview;/** *  * <p> * title: tabswitcher.java * </p> * <p> * e-mail: 176291935@qq.com * </p> * <p> * qq: 176291935 * </p> * <p> * http: iaiai.iteye.com * </p> * <p> * create time: 2011-8-11 * </p> *  * @author 丸子 * @version 0.0.1 */public class tabswitcher extends linearlayout {	private context context;	private string[] texts;	private int selectedposition = 0;	private int oldposition = selectedposition;	private int[] background = { r.drawable.tabswitcher_short,			color.transparent };	private textview[] tvs;	public tabswitcher(context context, string[] texts) {		super(context);		this.texts = texts;		this.context = context;		setorientation(horizontal);		linearlayout.layoutparams params = new linearlayout.layoutparams(				linearlayout.layoutparams.fill_parent,				linearlayout.layoutparams.wrap_content);		setlayoutparams(params);		setbackgroundresource(r.drawable.tabswitcher_long);	}	@override	protected void onfinishinflate() {		// todo auto-generated method stub		super.onfinishinflate();		tvs = new textview[texts.length];		linearlayout.layoutparams params = new linearlayout.layoutparams(				linearlayout.layoutparams.fill_parent,				linearlayout.layoutparams.wrap_content);		params.weight = 1;		params.gravity = gravity.center_vertical;		for (int i = 0; i < texts.length; i++) {			textview child = new textview(context);			child.settag(i);			child.settextsize(16);			child.settextcolor(color.black);			child.setgravity(gravity.center);			tvs[i] = child;			child.setonclicklistener(listener);			this.addview(child, params);		}	}	onclicklistener listener = new onclicklistener() {		@override		public void onclick(view v) {			selectedposition = (integer) v.gettag();			if (selectedposition != oldposition) {				tvs[oldposition].setbackgroundcolor(background[1]);				oldposition = selectedposition;				((textview) v).setbackgroundresource(background[0]);				if (onitemclicklisener != null) {					onitemclicklisener.onitemclicklisener(v, selectedposition);				}			}		}	};	@override	protected void onsizechanged(int w, int h, int oldw, int oldh) {		super.onsizechanged(w, h, oldw, oldh);		oldposition = selectedposition;		for (int i = 0; i < texts.length; i++) {			tvs[i].settext(texts[i]);			if (selectedposition == i) {				tvs[i].setbackgroundresource(background[0]);			} else {				tvs[i].setbackgroundcolor(background[1]);			}		}	}	private onitemclicklisener onitemclicklisener;	public void setonitemclicklisener(onitemclicklisener onitemclicklisener) {		this.onitemclicklisener = onitemclicklisener;	}	public interface onitemclicklisener {		void onitemclicklisener(view view, int position);	}	public void settexts(string[] texts) {		this.texts = texts;	}	public void setselectedposition(int selectedposition) {		this.selectedposition = selectedposition;	}}
  


iaiaiactivity.java
    package com.iaiai.activity;import android.app.activity;import android.os.bundle;import android.view.view;import android.widget.linearlayout;import android.widget.toast;import com.iaiai.activity.tabswitcher.onitemclicklisener;/** *  * <p> * title: iaiaiactivity.java * </p> * <p> * e-mail: 176291935@qq.com * </p> * <p> * qq: 176291935 * </p> * <p> * http: iaiai.iteye.com * </p> * <p> * create time: 2011-8-11 * </p> *  * @author 丸子 * @version 0.0.1 */public class iaiaiactivity extends activity {	@override	public void oncreate(bundle savedinstancestate) {		super.oncreate(savedinstancestate);		setcontentview(r.layout.main);		tabswitcher tabswitcher = new tabswitcher(this, new string[] { "1",				"2", "3", "4" });		tabswitcher.setselectedposition(1);		tabswitcher.setonitemclicklisener(onitemclicklisener);		tabswitcher.onfinishinflate();				linearlayout linearlayout = (linearlayout) findviewbyid(r.id.tab);		linearlayout.addview(tabswitcher, new linearlayout.layoutparams(				linearlayout.layoutparams.fill_parent,				linearlayout.layoutparams.wrap_content));	}	onitemclicklisener onitemclicklisener = new onitemclicklisener() {		@override		public void onitemclicklisener(view view, int position) {			// todo auto-generated method stub			//			switch (position) {			case 0:			case 1:			case 2:				toast.maketext(iaiaiactivity.this,						"position clicked:" + position, toast.length_short)						.show();				break;			default:				break;			}		}	};}
  


tabswitcher_long.9.png:

tabswitcher_short.9.png:
?

Android TabSwitcher自定義控件


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 午夜在线免费观看 | 99热这里有免费国产精品 | 青娱乐在线视频观看 | 亚洲性猛交xx乱 | 一区二区三区四区国产 | 日日摸天天碰中文字幕 | 欧美国产中文 | 日本无卡码免费一区二区三区 | 久久精品中文字幕 | 一区二区三区不卡免费视频97 | 久久精品国产免费看久久精品 | 亚洲a网 | 久久这里只有精品免费看青草 | 欧美日韩国产一区二区三区不卡 | 黑色丝袜美女自安慰视频 | 欧美色综合天天久久综合精品 | 福利在线看 | 青青免费视频精品一区二区 | 欧美淫| 手机av在线 | 欧美精品一区在线发布 | 亚洲国产精品99久久久久久久久 | 国产精品视频成人 | 91久久夜色精品国产九色 | concern超碰在线 | 成人av播放 | 黄色av网站在线免费观看 | 午夜影院观看 | 91精品国模一区二区三区 | av免费网站在线观看 | 久草在线国产视频 | 成人在线观看免费视频 | 91不卡在线 | 天天操天天干天天 | 91免费大片| 国产精品久久久久久久久 | 久久黄视频 | 欧美日日操 | 欧美一区二区三区在线观看免费 | 久久av一区二区三区 | 亚洲精品在线播放视频 |