当前位置: 编程技术>移动开发
本页文章导读:
▪猕猴测试 猴子测试
With no options specified, the Monkey will launch in a quiet (non-verbose) mode, and will send events to any (and all) packages installed on your target. Here is a more typical command line, which will launch your application and send.........
▪ 第一章:具有抉择功能对话框 第一章:具有选择功能对话框
效果:main.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.........
▪ 替Activity屏幕的标题添加图标 为Activity屏幕的标题添加图标
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Window win = getWindow();
win.requestFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.my.........
[1]猕猴测试
来源: 互联网 发布时间: 2014-02-18
猴子测试
With no options specified, the Monkey will launch in a quiet (non-verbose) mode, and will send events to any (and all) packages installed on your target. Here is a more typical command line, which will launch your application and send 500 pseudo-random events to it:
$ adb shell monkey -p 【your.package.name】 -v 500
With no options specified, the Monkey will launch in a quiet (non-verbose) mode, and will send events to any (and all) packages installed on your target. Here is a more typical command line, which will launch your application and send 500 pseudo-random events to it:
$ adb shell monkey -p 【your.package.name】 -v 500
[2] 第一章:具有抉择功能对话框
来源: 互联网 发布时间: 2014-02-18
第一章:具有选择功能对话框
效果:
main.xml
strings.xml
效果:
main.xml
<?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout android:id="@+id/widget0" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" > <Button android:id="@+id/selcet" android:layout_width="95px" android:layout_height="wrap_content" android:text="选择" android:layout_x="123px" android:layout_y="189px" > </Button> </AbsoluteLayout>
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, AlertDialogTest!</string>
<string name="alert_select_title">请选择内容</string>
<string name="dialog_title">您选择的是:</string>
<string name="ok">确定</string>
<string name="cancel">取消</string>
<array name="alert_select_array">
<item>串串香</item>
<item>烤肉</item>
<item>火锅</item>
<item>肯德基</item>
</array>
<string name="app_name">AlertDialogTest</string>
</resources>
package alert.dialog.test;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class AlertDialogTest extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/**载入main.xml */
setContentView(R.layout.main);
/**通过id找到button组件*/
Button bt=(Button)findViewById(R.id.selcet);
/**设置button按钮点击事件*/
bt.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
/**设置对话框标题,内容点击事件*/
new AlertDialog.Builder(AlertDialogTest.this).setTitle(R.string.alert_select_title).setItems(R.array.alert_select_array, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
/**获得strings.xml name="dialog_title"内容*/
CharSequence strDialog=getString(R.string.dialog_title);
/**获得strings.xml name="alert_select_array"数组内容*/
String[] str=getResources().getStringArray(R.array.alert_select_array);
new AlertDialog.Builder(AlertDialogTest.this).setMessage(strDialog+ str[which]).setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
/**为选择对话框设置取消按钮事件*/
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).show();
}
});
}
}
[3] 替Activity屏幕的标题添加图标
来源: 互联网 发布时间: 2014-02-18
为Activity屏幕的标题添加图标
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Window win = getWindow();
win.requestFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.mylayout);
win.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon);
}
其中要注意的是,win.setFeatureDrawableResource必须在setContentView之后,不然就没有效果。
最新技术文章: