标题:关于自定义EditText,求助!
只看楼主
绝爱小朱
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2013-3-26
结帖率:33.33%
已结贴  问题点数:38 回复次数:1 
关于自定义EditText,求助!
下面是我实现自定义控件代码:
public class MyEditText extends LinearLayout {
    private EditText mEditText;
    private Button bAdd;
    private Button bReduce;

    public MyEditText(final Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    protected void onFinishInflate() {
        super.onFinishInflate();

        LayoutInflater.from(getContext()).inflate(R.layout.myedittext, this);
        init_widget();
        addListener();

    }

    public void init_widget() {

        mEditText = (EditText) findViewById(R.id.et01);
        bAdd = (Button) findViewById(R.id.bt01);
        bReduce = (Button) findViewById(R.id.bt02);
        mEditText.setText("1");
    }

    public void addListener() {
        bAdd.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub

                int num = Integer.valueOf(mEditText.getText().toString());
                num++;
                mEditText.setText(Integer.toString(num));
            }
        });

        bReduce.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                int num = Integer.valueOf(mEditText.getText().toString());
                num--;
                mEditText.setText(Integer.toString(num));
            }
        });
    }

}
问题来了,如何在别的页面加载这个控件后改变文本框里面的初始值;
搜索更多相关主题的帖子: private public super 
2014-03-13 16:50
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
得分:38 
路过
2014-03-13 20:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-428466-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.353114 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved