<
item
android:drawable
=
@H_502_23@"
@H_502_23@@android:color/transparent
@H_502_23@"
/>
<!-- default :默认的图形-->
</
selector
>
------------------------------------------------------------------------------------------------
android:background=@H_502_23@"@drawable/home_item_selector"
>
<
ImageView
/>
<
TextView
/>
</
LinearLayout
>
-------------------------------------------------------------------------------------------
public
class
MainActivity
extends
Activity {
private
GridView
gv_home
;
"系统优化"
,
"高级工具"
,
"程序设置"
};
private
int
[]
icons
= { R.drawable.
@H_502_23@icon_safe_selector
,R.drawable.
@H_502_23@icon_call_selector
,
R.drawable.
@H_502_23@icon_app_selector
,R.drawable.
@H_502_23@icon_task_selector
,R.drawable.
@H_502_23@icon_net_selector
,R.drawable.
@H_502_23@icon_trojan_selector
,
R.drawable.
@H_502_23@icon_sys_selector
,R.drawable.
@H_502_23@icon_atools_selector
,R.drawable.
@H_502_23@icon_setting_selector
};
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
//填充界面
gv_home
.setAdapter(
new
HomeAdapter());
//跳转模块界面
gv_home
.setOnItemClickListener(
new
OnItemClickListener() {
@Override
public
void
onItemClick(AdapterView<?> parent,View view,
int
position,
long
id) {
switch
(position) {
case
8:
Intent intent_setting=
new
Intent(MainActivity.
this
,SettingActivity.
class
);
startActivity(intent_setting);
break
;
}
}
});
}
/**
* 创建适配器
*
@author
Administrator
*
*/
private
class
HomeAdapter
extends
BaseAdapter{
@Override
public
int
getCount() {
return
names
.
length
;
}
@Override
public
View getView(
int
position,View convertView,ViewGroup parent) {
//创建填充器
View view = View.@H_502_23@inflate(getApplicationContext(),R.layout.
@H_502_23@grid_home_item
,
null
);
iv_item_icon.setImageResource(
icons
[position]);
tv_item_name.setText(
names
[position]);
return
view;
}
@Override
public
Object getItem(
int
position) {
//
TODO
Auto-generated method stub
return
null
;
}
@Override
public
long
getItemId(
int
position) {
//
TODO
Auto-generated method stub
return
0;
}
}
}