当前位置: 编程技术>移动开发
本页文章导读:
▪调剂屏幕亮度 调节屏幕亮度
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 1.0f;
getWindow().setAttributes(lp);
......
▪ 动态增添lsitView 动态添加lsitView
这个很简单 就是为了说明别忘了adapter.notifyDataSetChanged();
唤醒一下,其实这个唤醒也就是在buutton下用 或者在别的控件下调用 如果是在getView下就不必了
ublic class DynamicListItems .........
▪ 设立listview中的item的颜色 设置listview中的item的颜色
设置listview中每一item的颜色新建drawable/item_bk.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
androi.........
[1]调剂屏幕亮度
来源: 互联网 发布时间: 2014-02-18
调节屏幕亮度
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 1.0f;
getWindow().setAttributes(lp);
[2] 动态增添lsitView
来源: 互联网 发布时间: 2014-02-18
动态添加lsitView
这个很简单 就是为了说明别忘了adapter.notifyDataSetChanged();
唤醒一下,其实这个唤醒也就是在buutton下用 或者在别的控件下调用 如果是在getView下就不必了
ublic class DynamicListItems extends ListActivity {
private static final String ITEM_KEY = "key";
ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
private SimpleAdapter adapter;
private EditText newValue;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dynamic_list);
newValue = (EditText) findViewById(R.id.new_value_field);
setListAdapter(new SimpleAdapter(this, list, R.layout.row, new String[] { ITEM_KEY }, new int[] { R.id.list_value }));
((ImageButton) findViewById(R.id.button)).setOnClickListener(getBtnClickListener());
}
private OnClickListener getBtnClickListener() {
return new OnClickListener() {
public void onClick(View view) {
try {
HashMap<String, String> item = new HashMap<String, String>();
item.put(ITEM_KEY, newValue.getText().toString());
list.add(item);
adapter.notifyDataSetChanged();
} catch (NullPointerException e) {
Log.i("[Dynamic Items]", "Tried to add null value");
}
}
};
}
}
<?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"
>
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"
android:cacheColorHint="#00000000">
</ListView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6px"
android:layout_marginBottom="8px"
android:layout_marginLeft="8px"
android:layout_marginRight="8px"
android:background="#00000000">
<ImageButton
android:id="@+id/button"
android:layout_width="100px"
android:layout_height="100px"
android:src="/blog_article/@android_drawable/ic_menu_add/index.html" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="230px"
android:layout_height="wrap_content"
android:layout_marginTop="8px"
android:layout_marginBottom="8px"
android:layout_marginLeft="0px"
android:layout_marginRight="28px"
android:background="#cccccc00" >
<EditText android:id="@+id/new_value_field"
android:textColor="#020905"
android:textSize="18sp"
android:layout_marginTop="6px"
android:layout_marginBottom="8px"
android:layout_marginLeft="12px"
android:layout_marginRight="12px"
android:layout_width="210px"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
row
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00000000">
<TextView
android:id="@+id/list_value"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
[3] 设立listview中的item的颜色
来源: 互联网 发布时间: 2014-02-18
设置listview中的item的颜色
设置listview中每一item的颜色
新建drawable/item_bk.xml
然后在listview里面加入:
如果要让每一个item点击时的背景没有,使用在selector中用android:drawable="@android:color/transparent"就行
可以参考下http://stackoverflow.com/questions/2562051/listview-item-background-via-custom-selector
设置listview中每一item的颜色
新建drawable/item_bk.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
android:drawable="@color/trans" />
<item android:state_focused="true" android:drawable="@color/trans"></item>
<item android:state_pressed="true" android:drawable="@color/trans"></item>
</selector>
然后在listview里面加入:
android:listSelector="@drawable/item_bk"
如果要让每一个item点击时的背景没有,使用在selector中用android:drawable="@android:color/transparent"就行
可以参考下http://stackoverflow.com/questions/2562051/listview-item-background-via-custom-selector
最新技术文章: