1.10 状态选择器: 就是一个xml配置文件
来源:互联网 发布:mysql事务select 编辑:程序博客网 时间:2024/05/21 10:13
<?xml version="1.0" encoding= "utf-8"?>
<selector xmlns:android= "http://schemas.android.com/apk/res/android" >
<item android:state_pressed ="true"
android:drawable= "@color/gray" /> <!-- pressed :当前条目被按下时显示指定图形-->
<item android:state_focused ="true"
android:drawable= "@color/gray" /> <!-- focused:获取焦点的时候 -->
<item android:drawable ="@android:color/transparent " /> <!-- default :默认的图形-->
</selector>
------------------------------------------------------------------------------------------------
<?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>
-------------------------------------------------------------------------------------------
public class MainActivity extends Activity {
private GridView gv_home;
private String[] names = { "手机防盗", "通讯卫士" , "软件管理" , "进程管理" , "流量统计" , "手机杀毒" ,
"系统优化", "高级工具" , "程序设置" };
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() {
@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. 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;
}
@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;
}
}
}
- 1.10 状态选择器: 就是一个xml配置文件
- 就是一个广搜加一个状态压缩
- 一个log4j.xml配置文件
- 一个AndroidManifest.xml 配置文件
- Android初级教程:如何自定义一个状态选择器
- 状态选择器
- 状态选择器
- 状态选择器
- 状态选择器
- 一个servlet,多个dwr.xml配置文件
- 一个servlet,多个dwr.xml配置文件
- 一个spring web的配置文件web.xml
- 【MyBatis】一个简单的xml配置文件;
- 服务器运行的状态,修改Spring中的applicationContext.xml配置文件
- 服务器运行的状态,修改Spring中的applicationContext.xml配置文件
- UIPickerView 就是Android的选择器
- selector 状态选择器详解
- Android状态选择器
- MySQL的日常管理
- hdu2795Billboard (线段树,看作点更新)
- android错误之android.util.AndroidRuntimeException: You cannot combine custom titles with other title
- Eclipse工程部署
- iOS UITableView 简单应用中的两个实现函数
- 1.10 状态选择器: 就是一个xml配置文件
- ODBC连接类函数
- Maximum path sum I Problem 18
- complex network1
- beautifulsoup的简单用法
- My Internal training Doc on Sencha Touch build Mobile Web Applications
- Linux_Linux指令CP
- 1.11 自定义组合控件
- 杭电题目分类