`

LayoutInflater

 
阅读更多

LayoutInflater:LayoutInflater的作用和findViewById()差不多,不同之处在于LayoutInflater是找layout文件夹下的某个xml布局文件!而 findViewById()是找某一个xml下的具体 widget控件。

 

	private void setTabIndicator(int icon, String title, Intent intent) {
		 
		 View localView = LayoutInflater.from(this.mTabHost.getContext()).inflate(R.layout.tab_style, null);
		 ((ImageView)localView.findViewById(R.id.main_activity_tab_image)).setBackgroundResource(icon);
		 ((TextView)localView.findViewById(R.id.main_activity_tab_text)).setText(title);
		 
		 
		 
		 TabHost.TabSpec localTabSpec = mTabHost.newTabSpec(title).setIndicator(localView).setContent(intent);
		 mTabHost.addTab(localTabSpec);
		 
		} 
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics