【问题标题】:android editText is not prints my input given to itandroid editText 不打印我给它的输入
【发布时间】:2017-08-02 05:47:13
【问题描述】:

这是我的代码,我的适配器为我的活动返回一个编辑文本视图

   public View getView(int i, View view, ViewGroup viewGroup) {
           LinearLayout linearLayout;
           linearLayout = new LinearLayout(context);
           linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
           linearLayout.setOrientation(LinearLayout.VERTICAL);
            EditText editText = new EditText(context);
            editText.setMinLines(1);
            linearLayout.addView(editText);
            return linearLayout;
    }

【问题讨论】:

  • 请澄清您的具体问题或添加其他详细信息以准确突出您的需要。正如目前所写的那样,很难准确地说出你在问什么。请参阅“如何提问”页面以获得澄清此问题的帮助。

标签: java android android-adapter


【解决方案1】:

使用这个我认为它可能会工作......

LinearLayout.LayoutParams param = new LinearLayout.LayoutParams
                       (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1f);

或者试试这个....

public View getView(int i, View view, ViewGroup viewGroup) {
           LinearLayout linearLayout;
           linearLayout = new LinearLayout(context);
         LinearLayout.LayoutParams param = new LinearLayout.LayoutParams
                   (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1f);

            linearLayout.setOrientation(LinearLayout.VERTICAL);
            EditText editText = new EditText(context);
            editText.setMinLines(1);
            editText.setLayoutParams(params);

            linearLayout.addView(editText);
            return linearLayout;
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多