阿福偏偏 2013-10-25 04:12
浏览 941

发送文本框里输入的内容

我想点击按钮时发送文本框里的内容,将文本框里的内容显示到自己用代码写的布局里,以下是我写的代码:
Time t=new Time();
t.setToNow();
int year=t.year;
int month=t.month+1;
int day=t.monthDay;
int hour=t.hour;
int minute=t.minute;
tt=year+"-"+month+"-"+day+" "+hour+":"+minute;
LinearLayout.LayoutParams p=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams vp=new LinearLayout.LayoutParams(100,1);
vp.setMargins(0, 5, 0, 0);
RelativeLayout.LayoutParams layltop=new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
layltop.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
LinearLayout ltop=new LinearLayout(UserReturnActivity.this);
ltop.setOrientation(LinearLayout.HORIZONTAL);
ltop.setLayoutParams(layltop);
View vleft=new View(UserReturnActivity.this);
View vlright=new View(UserReturnActivity.this);
vleft.setLayoutParams(vp);
vleft.setBackgroundColor(getResources().getColor(R.color.result_minor_text));
vlright.setLayoutParams(vp);
vlright.setBackgroundColor(getResources().getColor(R.color.result_minor_text));
TextView txtTime=new TextView(UserReturnActivity.this);
txtTime.setText(tt);
txtTime.setLayoutParams(p);
txtTime.setTextColor(getResources().getColor(R.color.result_minor_text));
ltop.addView(vleft);
ltop.addView(txtTime);
ltop.addView(vlright);
TextView txtInfo=new TextView(UserReturnActivity.this);
txtInfo.setText(str);
txtInfo.setBackgroundResource(R.drawable.umeng_fb_reply_right_bg);
RelativeLayout.LayoutParams laytxtinfo=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
laytxtinfo.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
laytxtinfo.addRule(RelativeLayout.BELOW, ltop.getId());
txtInfo.setLayoutParams(laytxtinfo);
RelativeLayout ll=new RelativeLayout(UserReturnActivity.this);
ll.addView(ltop,layltop);
ll.addView(txtInfo,laytxtinfo);
lineInfo.addView(ll);
editWoXiangShuo.setText("");
该段代码显示的结果为:ltop和txtinfo不是上下结构而是txtinfo把ltop给盖住了,怎没办?而且点击按钮后,没有显示出来,当再次点击文本框向文本框输入值时,才显示上次输入的内容。

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试