当前位置: 编程技术>移动开发
本页文章导读:
▪光标位置安插 光标位置插入
EditText mTextInput=(EditText)findViewById(R.id.input);//EditText对象int index = mTextInput.getSelectionStart();//获取光标所在位置String text="I want to input str";(方法1):Editable edit = mTextInput.getEditableTe.........
▪ 自定义Layout的根本框架 自定义Layout的基本框架
public class SimpleMenuView extends RelativeLayout implements OnClickListener {
private Context mContext;
public SimpleMenuView(Context context) {
super(context);
mContext = context;
}
public SimpleMenuView.........
▪ 1.兑现地图蒙版,处理碰创事件 1.实现地图蒙版,处理碰创事件
如题
......
[1]光标位置安插
来源: 互联网 发布时间: 2014-02-18
光标位置插入
EditText mTextInput=(EditText)findViewById(R.id.input);//EditText对象
int index = mTextInput.getSelectionStart();//获取光标所在位置
String text="I want to input str";
(方法1):
Editable edit = mTextInput.getEditableText();//获取EditText的文字
if (index < 0 || index >= edit.length() ){
edit.append(text);
}else{
edit.insert(index,text);//光标所在位置插入文字
}
(方法2):
mTextInput.getText().insert(index,text);//光标所在位置插入文字
EditText mTextInput=(EditText)findViewById(R.id.input);//EditText对象
int index = mTextInput.getSelectionStart();//获取光标所在位置
String text="I want to input str";
(方法1):
Editable edit = mTextInput.getEditableText();//获取EditText的文字
if (index < 0 || index >= edit.length() ){
edit.append(text);
}else{
edit.insert(index,text);//光标所在位置插入文字
}
(方法2):
mTextInput.getText().insert(index,text);//光标所在位置插入文字
[2] 自定义Layout的根本框架
来源: 互联网 发布时间: 2014-02-18
自定义Layout的基本框架
public class SimpleMenuView extends RelativeLayout implements OnClickListener {
private Context mContext;
public SimpleMenuView(Context context) {
super(context);
mContext = context;
}
public SimpleMenuView(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
}
public SimpleMenuView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mContext = context;
}
public void init(final ItemAction action) {
final Button btn01 = (Button) findViewById(R.id.btn_1);
final Button btn02 = (Button) findViewById(R.id.btn_2);
btn01.setOnClickListener(this);
btn02.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btn_1:
break;
default:
break;
}
}
}
//加载类方法
private void layoutInflater() {
LayoutInflater mInflater = getLayoutInflater();
if (simpleMenuView == null || simpleMenuView.getParent() == null) {
final SimpleMenuView menuView = (SimpleMenuView) mInflater.inflate(R.layout.menu_view, null);
simpleMenuView = menuView;
}
if (simpleMenuView.getParent() == null) {
RL.addView(simpleMenuView);
}
if (simpleMenuView != null) {
ItemAction action = new ItemAction();
action.text = "btn";
action.action = new Action();
simpleMenuView.init(action); // 初始化
}
}
// ItemAction可以设置自定义Layout各种属性, action为其事件
public static class ItemAction {
public String text;
public Action action;
}
public static class Action {
public void run(Button btn) {
}
}
[3] 1.兑现地图蒙版,处理碰创事件
来源: 互联网 发布时间: 2014-02-18
1.实现地图蒙版,处理碰创事件
如题
最新技术文章: