我想点击按钮时发送文本框里的内容,将文本框里的内容显示到自己用代码写的布局里,以下是我写的代码:
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 提建议
- 追加酬金
- 关注问题
- 邀请回答
-