<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
selector
xmlns:android
=
"http://schemas.android.com/apk/res/android"
>
<
item
android:state_pressed
=
"true"
<
item
android:state_focused
=
"true"
<
item
android:drawable
=
"
@android:color/transparent
"
/>
<!-- default :默认的图形-->
@H_502_353@
</
selector
>
@H_502_353@
@H_502_353@
------------------------------------------------------------------------------------------------
@H_502_353@
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
LinearLayout
xmlns:android
=
"http://schemas.android.com/apk/res/android"
android:layout_width
=
"match_parent"
android:layout_height
=
"match_parent"
android:orientation
=
"vertical"
android:background="@drawable/home_item_selector"
android:gravity
=
"center"
>
<
ImageView
android:id
=
"@+id/iv_item_icon"
android:src
=
"@drawable/app"
android:layout_width
=
"55dip"
android:layout_height
=
"55dip"
/>
<
TextView
android:id
=
"@+id/tv_item_name"
android:layout_width
=
"wrap_content"
android:layout_height
=
"wrap_content"
android:text
=
"手机防盗"
android:textColor
=
"#000000"
android:textSize
=
"16sp"
/>
</
LinearLayout
>
@H_502_353@
@H_502_353@
@H_502_353@
-------------------------------------------------------------------------------------------
public
class
MainActivity
extends
Activity {
private
GridView
gv_home
;
"系统优化"
,
"高级工具"
,
"程序设置"
};
@H_502_353@
private
int
[]
icons
= { R.drawable.
icon_safe_selector
,R.drawable.
icon_call_selector
,
R.drawable.
icon_app_selector
,R.drawable.
icon_task_selector
,R.drawable.
icon_net_selector
,R.drawable.
icon_trojan_selector
,
R.drawable.
icon_sys_selector
,R.drawable.
icon_atools_selector
,R.drawable.
icon_setting_selector
};
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.
activity_main
);
gv_home
=(GridView) findViewById(R.id.
gv_home
);
//填充界面
gv_home
.setAdapter(
new
HomeAdapter());
//跳转模块界面
gv_home
.setOnItemClickListener(
new
OnItemClickListener() {
@H_502_353@
@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
;
@H_502_353@
}
}
});
}
/**
* 创建适配器
*
@author
Administrator
*
*/
private
class
HomeAdapter
extends
BaseAdapter{
@H_502_353@
@Override
public
int
getCount() {
return
names
.
length
;
}
@Override
public
View getView(
int
position,View convertView,ViewGroup parent) {
//创建填充器
View view = View.inflate(getApplicationContext(),R.layout.
grid_home_item
,
null
);
ImageView iv_item_icon=(ImageView) view.findViewById(R.id.
iv_item_icon
);
TextView tv_item_name=(TextView) view.findViewById(R.id.
tv_item_name
);
iv_item_icon.setImageResource(
icons
[position]);
tv_item_name.setText(
names
[position]);
return
view;
}
@H_502_353@
@Override
public
Object getItem(
int
position) {
//
TODO
Auto-generated method stub
return
null
;
}
@H_502_353@
@Override
public
long
getItemId(
int
position) {
//
TODO
Auto-generated method stub
return
0;
}
@H_502_353@
}
}
@H_502_353@