before里面content 里面的文字怎么换行
2个回答
展开全部
根据本人测试:将数据封装到模型类后,在Java文件中使用textViewObj.setText(obj.getXXX()).
无论是模拟器中,还是真机中,均可换行。
测试代码:
public class test extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tx = (TextView) findViewById(R.id.hello);
Man m = new Man();
m.setAdd("aaaaa\nbbbb");
m.setName("dddd\ncccc");
tx.setText(m.getAdd());
}
}
Man类代码:
public class Man {
String name;
String add;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAdd() {
return add;
}
public void setAdd(String add) {
this.add = add;
}
}
无论是模拟器中,还是真机中,均可换行。
测试代码:
public class test extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tx = (TextView) findViewById(R.id.hello);
Man m = new Man();
m.setAdd("aaaaa\nbbbb");
m.setName("dddd\ncccc");
tx.setText(m.getAdd());
}
}
Man类代码:
public class Man {
String name;
String add;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAdd() {
return add;
}
public void setAdd(String add) {
this.add = add;
}
}
追问
可以用css和html做不呢 Java的看不懂啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询