当前位置: 编程技术>移动开发
本页文章导读:
▪gallery 展示文字 gallery 显示文字
有时候想 向左向右设置文字的变化 不妨试试gallery
"demo.xml"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget44"
an.........
▪ savedInstanceState 的功用 savedInstanceState 的作用
笼统定义:在每个Activity对象被killed之前(有条件的),savedInstanceState 用来保存每个对象的状态。
举个例子,有两个activity的实例,分别为A,B, A先启动,然后B再启.........
▪ BroadcastReceiver 示例 【原创】BroadcastReceiver 示例
package com.firewings.smstools;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class SmsReceiver extends B.........
[1]gallery 展示文字
来源: 互联网 发布时间: 2014-02-18
gallery 显示文字
有时候想 向左向右设置文字的变化 不妨试试gallery
"demo.xml"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget44"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal">
<TextView
android:id="@+id/txt1_gvi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#051b4d"
android:gravity="center_horizontal"
android:textColorHighlight="#656565"
android:textSize="10sp">
</TextView>
</LinearLayout>
public Activity activity;
private static LayoutInflater inflater=null;
private String [] stringid=new String[]{"Index-Nifty","Positional calls","Intraday calls","InvestmentIdea","Optional calls","BTST-STBT calls"};
public TabGallary(Activity a) {
activity = a;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount(){
return stringid.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
View v;
if (convertView == null)
{
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.demo, null);
TextView tv1 = (TextView)v.findViewById(R.id.txt1_gvi);
tv1.setText(stringid[position]);
v.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// Call intent or perform ur activity;
}
});
}
else
{
v= convertView;
}
return v;
}
[2] savedInstanceState 的功用
来源: 互联网 发布时间: 2014-02-18
savedInstanceState 的作用
笼统定义:在每个Activity对象被killed之前(有条件的),savedInstanceState 用来保存每个对象的状态。
举个例子,有两个activity的实例,分别为A,B, A先启动,然后B再启动遮挡住了A, 这时候如果系统的内存不足,系统就会暂时回收A,因为此时A是被遮挡的,对用户不可见的! 在回收A之前要做一些保存实例状态的工作,因为在B回返的时候,A还是要被重新创建并显示给用户的。
在activiy被回收的时候,它会调用 onSaveInstanceState(Bundle) 这个回调保存activity的状态,在恢复的时候会调用 onRestoreInstanceState(Bundle) 这个回调恢复系统状态,他们都是有默认实现的,如果你要添加非默认的状态,需要在这两个方法里自己添加。
[3] BroadcastReceiver 示例
来源: 互联网 发布时间: 2014-02-18
【原创】BroadcastReceiver 示例
package com.firewings.smstools;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class SmsReceiver extends BroadcastReceiver {
private static String START_ACTION = "com.firewings.smstools.START";
private static String STOP_ACTION = "com.firewings.smstools.STOP";
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
String action = intent.getAction();
if (STOP_ACTION.equalsIgnoreCase(action)) {
context.stopService(new Intent(context, SmsListener.class));
} else {
context.startService(new Intent(context, SmsListener.class));
}
}
}
最新技术文章: