Android 特殊用法介绍
2010-05-29 05:19:00 来源:WEB开发网< shape xmlns:android ="http://schemas.android .com/apk/res/android " android :shape="rectangle" >
< gradient android :startColor="#FFFFFFFF" android :endColor="#FFFF0000"
android :angle="270"/ >
< /shape >
在该文件中设置渐变的开始颜色(startColor)、结束颜色(endColor)和角度(angle)
接着创建一个主题values/style.xml
< ?xml version="1.0" encoding="utf-8"? >
< resources >
< style name="NewTheme" parent="android :Theme" >
< item name="android :background" >@drawable/shape< /item >
< /style >
< /resources >
然后在AndroidManifest.xml文件中的application或activity中引入该主题,如:
< activity android :name=".ShapeDemo" android :theme="@style/NewTheme" >
该方法同样适用于控件 http://17f8.cn/trackback.php?tbID=259&extra=9d45e9
12. 储存数据 当你在一个实例中保存静态数据,此示例关闭后 下一个实例想引用 静态数据就会为null,这里呢必须重写applition
public class MyApplication extends Application{
private String thing = null;
public String getThing(){
return thing;
}
public void setThing( String thing ){
this.thing = thing; }
}
public class MyActivity extends Activity {
private MyApplication app;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = ((MyApplication)getApplication());
String thing = app.getThing();
}
}
更多精彩
赞助商链接