Adroid相关问题收集

1、在一个Activity中在一个点击事件时执行 startActivityForResult(intent, 0); 跳转到第二个Activity上后,再从第二个Activity上传回结果给第一个Activity时调用setResult(RESULT_OK, intent); 后,但第一个Activity中的onActivityResult()方法接收的resultCodesetResult设置的不致,解决方法是:把manifest中的Activity属性的singleTask去掉即可。

2、在java类中设置按钮按下状态改变图片

 private OnTouchListener touchListener = new OnTouchListener() {
	/**
	 * set the button up and down state
	 */
	public boolean onTouch(View v, MotionEvent event) {
	    switch (v.getId()) {
	    case R.id.act_item_buy_btn:
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
		    v.setBackgroundResource(R.drawable.order_btn_click);
		}
		if (event.getAction() == MotionEvent.ACTION_UP
			|| event.getAction() == MotionEvent.ACTION_CANCEL) {
		    v.setBackgroundResource(R.drawable.order_btn);
		}
		break;
	    case R.id.act_item_share_btn:
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
		    v.setBackgroundResource(R.drawable.share_btn_click);
		}
		if (event.getAction() == MotionEvent.ACTION_UP
			|| event.getAction() == MotionEvent.ACTION_CANCEL) {
		    v.setBackgroundResource(R.drawable.share_btn);
		}
		break;
	    default:
		break;
	    }
	    return false;
	}
    };
 

3、EditText输入文本控制

<EditText android:layout_width="fill_parent" android:layout_height="wrap_content"android:inputType="phone" />
//文本类型,多为大写、小写和数字符号。
    android:inputType="none"
    android:inputType="text"
    android:inputType="textCapCharacters" 字母大写
    android:inputType="textCapWords" 首字母大写
    android:inputType="textCapSentences" 仅第一个字母大写
    android:inputType="textAutoCorrect" 自动完成
    android:inputType="textAutoComplete" 自动完成
    android:inputType="textMultiLine" 多行输入
    android:inputType="textImeMultiLine" 输入法多行(如果支持)
    android:inputType="textNoSuggestions" 不提示
    android:inputType="textUri" 网址
    android:inputType="textEmailAddress" 电子邮件地址
    android:inputType="textEmailSubject" 邮件主题
    android:inputType="textShortMessage" 短讯
    android:inputType="textLongMessage" 长信息
    android:inputType="textPersonName" 人名
    android:inputType="textPostalAddress" 地址
    android:inputType="textPassword" 密码
    android:inputType="textVisiblePassword" 可见密码
    android:inputType="textWebEditText" 作为网页表单的文本
    android:inputType="textFilter" 文本筛选过滤
    android:inputType="textPhonetic" 拼音输入
//数值类型
    android:inputType="number" 数字
    android:inputType="numberSigned" 带符号数字格式
    android:inputType="numberDecimal" 带小数点的浮点格式
    android:inputType="phone" 拨号键盘
    android:inputType="datetime" 时间日期
    android:inputType="date" 日期键盘
    android:inputType="time" 时间键盘

4、


猜你喜欢

转载自zwnjava.iteye.com/blog/1652204