当前位置: 编程技术>移动开发
本页文章导读:
▪改变ToggleButton的图片及Button背景的更动 改变ToggleButton的图片及Button背景的更改
改变ToggleButton的图片http://wang-peng1.iteye.com/blog/556021在Android中使用自定义图片按钮http://android.yaohuiji.com/archives/461对某些控件的样式,外观的的修改的.........
▪ 运用界面主题Theme使用方法 应用界面主题Theme使用方法
主题Theme就是用来设置界面UI风格,可以设置整个应用或者某个活动Activity的界面风格。在Android SDK中内置了下面的Theme,可以按标题栏Title Bar和状态栏Status Bar是.........
▪ listview兑现单选功能 listview实现单选功能
package com.xiaoming;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button.........
[1]改变ToggleButton的图片及Button背景的更动
来源: 互联网 发布时间: 2014-02-18
改变ToggleButton的图片及Button背景的更改
改变ToggleButton的图片
http://wang-peng1.iteye.com/blog/556021
在Android中使用自定义图片按钮
http://android.yaohuiji.com/archives/461
对某些控件的样式,外观的的修改的思考
Android应用开发笔记(10):制作自定义背景Button按钮、自定义形状Button的全攻略
http://blog.csdn.net/xjanker2/article/details/6222690
http://www.cnblogs.com/mainroadlee/archive/2011/01/09/Change_the_background_image_based_on_the_state_of_the_button_on_Android.html
有效
改变ToggleButton的图片
http://wang-peng1.iteye.com/blog/556021
在Android中使用自定义图片按钮
http://android.yaohuiji.com/archives/461
对某些控件的样式,外观的的修改的思考
Android应用开发笔记(10):制作自定义背景Button按钮、自定义形状Button的全攻略
http://blog.csdn.net/xjanker2/article/details/6222690
http://www.cnblogs.com/mainroadlee/archive/2011/01/09/Change_the_background_image_based_on_the_state_of_the_button_on_Android.html
有效
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/btn_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/btn_normal" /> <!-- focused -->
<item android:drawable="@drawable/btn_normal" /> <!-- default -->
</selector>
[2] 运用界面主题Theme使用方法
来源: 互联网 发布时间: 2014-02-18
应用界面主题Theme使用方法
主题Theme就是用来设置界面UI风格,可以设置整个应用或者某个活动Activity的界面风格。在Android SDK中内置了下面的Theme,可以按标题栏Title Bar和状态栏Status Bar是否可见来分类:
这些主题可以应用到整个应用Application范围或者某个活动Activity范围中。
应用Application范围
在AndroidManifest.xml中的application节点中设置theme属性,主题theme应用到整个应用程序中。
<application
Android:icon=”@drawable/icon”
Android:icon=”@string/app_name”
Android:icon=”@android:style/ Theme.Black.NoTitleBar”>
活动Activity范围
使用java代码或者在AndroidManifest.xml中对活动Activity的主题进行设置,主题仅应用到当前活动中。
在AndroidMainifest.xml设置方法:
<activity
android:name=“.About”
android:label=“@string/app_name”
android:theme=“@android:style/ Theme.Black.NoTitleBar” >
使用java代码进行设置,在当前活动Activity的onCreate中进行设置:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
setContentView(R.layout.main);
}
原文链接:http://blog.csdn.net/feng88724/article/details/6457431
主题Theme就是用来设置界面UI风格,可以设置整个应用或者某个活动Activity的界面风格。在Android SDK中内置了下面的Theme,可以按标题栏Title Bar和状态栏Status Bar是否可见来分类:
•android:theme="@android:style/Theme.Dialog" 将一个Activity显示为能话框模式 •android:theme="@android:style/Theme.NoTitleBar" 不显示应用程序标题栏 •android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不显示应用程序标题栏,并全屏 •android:theme="Theme.Light" 背景为白色 •android:theme="Theme.Light.NoTitleBar" 白色背景并无标题栏 •android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,无标题栏,全屏 •android:theme="Theme.Black" 背景黑色 •android:theme="Theme.Black.NoTitleBar" 黑色背景并无标题栏 •android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,无标题栏,全屏 •android:theme="Theme.Wallpaper" 用系统桌面为应用程序背景 •android:theme="Theme.Wallpaper.NoTitleBar" 用系统桌面为应用程序背景,且无标题栏 •android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系统桌面为应用程序背景,无标题栏,全屏 •android:theme="Translucent" 半透明 •android:theme="Theme.Translucent.NoTitleBar" 半透明、无标题栏 •android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 半透明、无标题栏、全屏 •android:theme="Theme.Panel" •android:theme="Theme.Light.Panel"
这些主题可以应用到整个应用Application范围或者某个活动Activity范围中。
应用Application范围
在AndroidManifest.xml中的application节点中设置theme属性,主题theme应用到整个应用程序中。
<application
Android:icon=”@drawable/icon”
Android:icon=”@string/app_name”
Android:icon=”@android:style/ Theme.Black.NoTitleBar”>
活动Activity范围
使用java代码或者在AndroidManifest.xml中对活动Activity的主题进行设置,主题仅应用到当前活动中。
在AndroidMainifest.xml设置方法:
<activity
android:name=“.About”
android:label=“@string/app_name”
android:theme=“@android:style/ Theme.Black.NoTitleBar” >
使用java代码进行设置,在当前活动Activity的onCreate中进行设置:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
setContentView(R.layout.main);
}
原文链接:http://blog.csdn.net/feng88724/article/details/6457431
[3] listview兑现单选功能
来源: 互联网 发布时间: 2014-02-18
listview实现单选功能
布局文件:
适配器不在acitivyt里面,则把activity传到适配器里面去
package com.xiaoming;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class MainActivity extends Activity {
private static final String TAG = "WZP13_RadioGroupActivity";
private ListView listView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
listView = (ListView) this.findViewById(R.id.list);
MyAdapter adapter = new MyAdapter();
listView.setAdapter(adapter);
}
private class MyAdapter extends BaseAdapter {
private String[] s = new String[] { "小天AAA", "小天BBB", "小天CCC", "小天DDD"};
private int temp = -1;
@Override
public int getCount() {
// TODO Auto-generated method stub
return s.length;
}
@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;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = MainActivity.this.getLayoutInflater()
.inflate(R.layout.item, null);
Button button = (Button) convertView.findViewById(R.id.button);
button.setText(s[position]);
RadioButton radioButton = (RadioButton) convertView
.findViewById(R.id.radioButton);
radioButton.setId(position);
radioButton
.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
if (temp != -1) {
RadioButton tempButton = (RadioButton) MainActivity.this
.findViewById(temp);
if (tempButton != null) {
tempButton.setChecked(false);
}
}
temp = buttonView.getId();
Log.i(TAG, "you are women- - " + isChecked
+ " " + temp);
}
}
});
if (temp == position) {
radioButton.setChecked(true);
}
return convertView;
}
}
}
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="测试" >
</Button>
<RadioButton
android:id="@+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<?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="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
适配器不在acitivyt里面,则把activity传到适配器里面去
最新技术文章: