我想点击按钮时发送文本框里的内容,将文本框里的内容显示到自己用代码写的布局里,以下是我写的代码:
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 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
0条回答
悬赏问题
- ¥15 C++ 头文件/宏冲突问题解决
- ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
- ¥50 安卓adb backup备份子用户应用数据失败
- ¥20 有人能用聚类分析帮我分析一下文本内容嘛
- ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
- ¥30 python代码,帮调试
- ¥15 #MATLAB仿真#车辆换道路径规划
- ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
- ¥15 数据可视化Python
- ¥15 要给毕业设计添加扫码登录的功能!!有偿