导航:首页 > 操作系统 > android写入文件换行

android写入文件换行

发布时间:2022-12-18 15:46:34

㈠ 安卓开发应用中text中如何自由让文本换行,想在哪换就在哪换,详细点哦!多谢多谢!我是菜鸟。

TextView中显示文本,让文本换行,第一种:设置TextView的宽和高,第二种:设置属性maxLength来设置最多显示字数,第三种:就是显示的文本中想换行的位置加\n!

android中用XmlSerializer写xml怎样实现换行和缩进

虽然时间过去了很久,但我还是要来回答,因为还有别人会需要,而我发现了。

serializer.text("\n\t\t");可以实现换行和空格

比如说
serializer.startTag(null, "name");
serializer.text("123");
serializer.text("\n\n");
serializer.endTag(null, "name");
那么输出的会是:
<name>123

</name>

㈢ android textview怎么处理换行

<1>如果直接在XML文件中写入"aaaaa\nbbbb"可以换行。
<2>在java文件中用textViewObj.setText("aaaa\nbbbb")也可以换行。

㈣ 安卓手机打字怎么换行

安卓手机打字换行的方法:

1、首先打开安卓手机的主界面;

2、再打开需要输入文字的页面;

3、在页面中点击输入框,出现输入法以后开始打字;

4、选择最右下角的“换行键”或者“回车键”,点击即可换行。



文字输入是安卓手机的一项基本操作功能,在使用安卓手机打字时,根据具体需要,可以对文字进行换行输入,首先解锁安卓手机的主界面,确保接下来的正常操作;在手机中打开编辑文字的软件,点击进入;在输入文字界面中点击输入框,会出现虚拟键盘的相关界面;在该界面上,选择最右下角的回车键图标即可,有的输入法会直接出现换行,点击即可。

需要注意的是安卓手机在输入文字的时候或在消息输入窗口,突然没有反应,或无法弹出输入法键盘,从而无法输入,这类情况有可能是输入法无响应,即运行不顺畅卡死,需要耐心等待或关闭后重新启动。

㈤ android textview 怎么换行

textView如果想要强制换行的话,必须先把TextView显示方式修改为多行(android:singleLine="false"),然后才能换行。
方法一般用两种:

1、在字符串里加入“ ”,如"abc rc";

2、把TextView设置为固定宽度,然后让系统自动换行。如android:layout_width="100dp";

(5)android写入文件换行扩展阅读

Class Overview

向用户显示文本,并可选择允许他们编辑文本。TextView是一个完整的文本编辑器,但是基类为不允许编辑;其子类EditText允许文本编辑。

允许用户复制部分或全部内容,将其粘贴到别的地方,设置XML属性Android:textisselectable :“真” 或设置相关方法 settextisselectable 为“真”。textisselectable flag 允许用户在TextView选择手势,从而触发系统内置的复制/粘贴控件。

Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; seeEditTextfor a subclass that configures the text view for editing.

To allow users to some or all of the TextView's value and paste it somewhere else, set the XML attributeandroid:textIsSelectableto "true" or callsetTextIsSelectable(true). ThetextIsSelectableflag allows users to make selection gestures in the TextView, which in turn triggers the system's built-in /paste controls.

㈥ 极光推送android端怎么自动换行内容

第一步:创建极光推送开发者帐号
要创建极光推送开发者帐号,请访问极光推送官方网站

第二步:Portal上创建应用
创建帐号进入极光推送后,首先显示的是创建应用的界面。填上你的应用程序的名称,以及 Android包名这二顶就可以了。

第三步:下载应用Example
创建帐号进入极光推送后,首先显示的是创建应用的界面。填上你的应用程序的名称,以及 Android包名这二顶就可以了。

点击 ”下载应用Example “后,你将下载到一个 .zip 压缩文件。解压后,即看到一个同名目录。这个目录下,是一个 Android 项目里的所有文件。

第四步:把Example(Android项目)导入 Eclipse 里
在你的 Eclipse 里,新建一个项目,把项目目录位置指向上步骤解压缩开的 Example目录。

第五步:运行 Example 这个应用
在你的 Eclipse 里,新建一个项目,把项目目录位置指向上步骤解压缩开的 Example目录。

如果你的 Android 手机接在电脑上了,则这个 JPush Example 应用就可以安装上,并运行起来了。
做下一步动作之前,请确保你的手机上的网络是可用的。
第六步:Portal上推送通知

第七步:手机上收到通知
在上述步骤安装 JPush Example 的手机上,你就可以收到推送的通知了。

第八步:Portal上推送消息

第九步:在LogCat中查看收到的消息
推送消息可以在LogCat日志中查看,开发者根据自己需要做展现处理,Jpush不做干预。

㈦ Android文本换行问题。

根据本人测试:将数据封装到模型类后,在Java文件中使用textViewObj.setText(obj.getXXX()).

无论是模拟器中,还是真机中,均可换行。

测试代码:

{

/**.*/

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

TextViewtx=(TextView)findViewById(R.id.hello);

Manm=newMan();

m.setAdd("aaaaa bbbb");

m.setName("dddd cccc");

tx.setText(m.getAdd());

}

}

Man类代码:

publicclassMan{

Stringname;

Stringadd;

publicStringgetName(){

returnname;

}

publicvoidsetName(Stringname){

this.name=name;

}

publicStringgetAdd(){

returnadd;

}

publicvoidsetAdd(Stringadd){

this.add=add;

}

}

附上一张运行图片吧。

㈧ 用android 安卓手机建立的文本文档,文档中的换行和空格,在windows电脑端不显示,或者将换

这是windows与linux系统的编码模式不同造成的。android系统是linux内核,与windows不同。windows是采用的是DOS编码方式,所用的换行符是DOS换行符CR/LF,也就是我们俗称的\r\n,(如果不理解可以去网络一下转义字符,一般程序员会用到这些知识),而linux系统的换行符为UNIX换行符LF,也就是\n,苹果的MAC系统用的是MAC换行符CR,也就是\r,现在我想你也差不多理解了。你在android手机里建立的文档肯定用的是UNIX换行符,也就是一个\n,但是这个文档你拿到windows里用记事本打开的话,因为windows记事本是DOS换行符\r\n,所以你少了个\r,所以没法识别成换行,只能给你识别成一个小方块了,解决办法很简单,你可以用EditPlus或者UltraEdit软件打开,UltraEdit也能转换这些编码模式,转换成DOS模式就可以了。

㈨ android LinearLayout 里面的东西怎么换行

由于前段时间项目中使用到了自动换行的线性布局,本来打算用表格布局在里面一个个的用Java代码添加ImageView的,但是添加的View控件是不确定的,因为得靠服务器的数据返回,就这样手动用Java代码画布局的方式就这样夭折了,因为在表哥布局中我无法确定一行显示多少个ImageView的数目,所以无法动态添加,最后自能自己去看看那种能够换行的线性布局了,线性布局比较不好的是不能自动换行,也就是当设置LinearLayout的orentation 设置为vertical 为竖直方向也就是只有一列,每行只能显示一个View或者View的子类,当设置LinearLayout的orentitation为Horizontal,LinearLayout的只能显示为一行,横向显示,当屏幕满了的时候,View控件并不会自动换行,所以我们要做的就是在LinearLayout满的时候自动换行。
需要了解的是怎么样绘制根据子控件的长宽绘制父控件的宽度与高度,所以需要传入的参数控件的高度,视图分为两种一种是View类型的,代表控件有TextView,Button,EditText 等等,还有一种是装视图的容器控件继承自ViewGroup的控件,如LinearLayout,RelativeLayout,TabHost等等控件,需要自动换行的线性布局的话,就需要根据子控件的高度与宽度,来动态加载父控件的高度与宽度,所以需要在构造函数中传入每一个子控件的固定的高度,或者是动态设置子控件的高度与宽度。
将自定义的LinearLayout 也继承自ViewGroup 并且重写抽象类ViewGrouop的几个方法:onMeasure(),onLayout(),dispathDraw() 三个方法的意思分别是:第一个onMeasure()是用来计算控件以及子控件所占用的区域,第二个onLayout()是控制子控件的换行,第三个可写可不写,主要是用来绘制控件的边框,
自定义LinearLayout的代码如下:

[java] view plainprint?
package com.huanglong.mylinearlayout;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

/**
* @author huanglong 2013-5-28 自定义自动换行LinearLayout
*/
public class FixGridLayout extends ViewGroup {
private int mCellWidth;
private int mCellHeight;

public FixGridLayout(Context context) {
super(context);
}

public FixGridLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}

public FixGridLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

public void setmCellWidth(int w) {
mCellWidth = w;
requestLayout();
}

public void setmCellHeight(int h) {
mCellHeight = h;
requestLayout();
}

/**
* 控制子控件的换行
*/
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int cellWidth = mCellWidth;
int cellHeight = mCellHeight;
int columns = (r - l) / cellWidth;
if (columns < 0) {
columns = 1;
}
int x = 0;
int y = 0;
int i = 0;
int count = getChildCount();
for (int j = 0; j < count; j++) {
final View childView = getChildAt(j);
// 获取子控件Child的宽高
int w = childView.getMeasuredWidth();
int h = childView.getMeasuredHeight();
// 计算子控件的顶点坐标
int left = x + ((cellWidth - w) / 2);
int top = y + ((cellHeight - h) / 2);
// int left = x;
// int top = y;
// 布局子控件
childView.layout(left, top, left + w, top + h);

if (i >= (columns - 1)) {
i = 0;
x = 0;
y += cellHeight;
} else {
i++;
x += cellWidth;

}
}
}

/**
* 计算控件及子控件所占区域
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// 创建测量参数
int cellWidthSpec = MeasureSpec.makeMeasureSpec(mCellWidth, MeasureSpec.AT_MOST);
int cellHeightSpec = MeasureSpec.makeMeasureSpec(mCellHeight, MeasureSpec.AT_MOST);
// 记录ViewGroup中Child的总个数
int count = getChildCount();
// 设置子空间Child的宽高
for (int i = 0; i < count; i++) {
View childView = getChildAt(i);
/*
* 090 This is called to find out how big a view should be. 091 The
* parent supplies constraint information in the width and height
* parameters. 092 The actual mesurement work of a view is performed
* in onMeasure(int, int), 093 called by this method. 094 Therefore,
* only onMeasure(int, int) can and must be overriden by subclasses.
* 095
*/
childView.measure(cellWidthSpec, cellHeightSpec);
}
// 设置容器控件所占区域大小
// 注意setMeasuredDimension和resolveSize的用法
setMeasuredDimension(resolveSize(mCellWidth * count, widthMeasureSpec),
resolveSize(mCellHeight * count, heightMeasureSpec));
// setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);

// 不需要调用父类的方法
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

/**
* 为控件添加边框
*/
@Override
protected void dispatchDraw(Canvas canvas) {
// 获取布局控件宽高
int width = getWidth();
int height = getHeight();
// 创建画笔
Paint mPaint = new Paint();
// 设置画笔的各个属性
mPaint.setColor(Color.BLUE);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(10);
mPaint.setAntiAlias(true);
// 创建矩形框
Rect mRect = new Rect(0, 0, width, height);
// 绘制边框
canvas.drawRect(mRect, mPaint);
// 最后必须调用父类的方法
super.dispatchDraw(canvas);
}

}
然后在Xml文件中引用自己定义的控件,在Java代码中调用:

[java] view plainprint?
package com.huanglong.mylinearlayout;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.CheckBox;
import android.widget.SimpleAdapter;
import android.support.v4.app.NavUtils;

public class MainActivity extends Activity {
private SimpleAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FixGridLayout fixGridLayout = (FixGridLayout) findViewById(R.id.ll);
fixGridLayout.setmCellHeight(30);
fixGridLayout.setmCellWidth(100);
for (int i = 0; i < 7; i++) {
CheckBox box = new CheckBox(MainActivity.this);
box.setText("第"+i+"个");
fixGridLayout.addView(box);
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

}

㈩ android 中组件怎么换行

应用中获取会用到需要自动换行的控件,而这并不是一般的线性或者相对布局就能实现的,在此分享下自定义控件。原型是在网上找到的,在此稍作了修改。
这是设计出的样稿,样稿中的较高的图片是从一个数据集中的穿插在另一个数据集中的,Textview的长度需要根据文字的长度不同而设置,而左右需要平分,做法如下:

1.将总体分为两个数据集:左&右,并用2个LinearLayout分别装自定义控件

android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip">

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">

android:layout_width="fill_parent"
android:layout_height="wrap_content">
</<span style="line-height: 21px;">PredicateLayout>

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<<span style="line-height: 21px;">PredicateLayout android:id="@+id/righttab"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</<span style="line-height: 21px;">PredicateLayout>

2.自定义控件
public class PredicateLayout extends LinearLayout {
int mLeft, mRight, mTop, mBottom;
Hashtable map = new Hashtable();
public PredicateLayout(Context context) {
super(context);
}
public PredicateLayout(Context context, int horizontalSpacing, int verticalSpacing) {
super(context);
}
public PredicateLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int mWidth = MeasureSpec.getSize(widthMeasureSpec);
int mCount = getChildCount();
int mX = 0;
int mY = 0;
mLeft = 0;
mRight = 0;
mTop = 5;
mBottom = 0;
int j = 0;
View lastview = null;
for (int i = 0; i < mCount; i++) {
final View child = getChildAt(i);

child.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
// 此处增加onlayout中的换行判断,用于计算所需的高度
int childw = child.getMeasuredWidth();
int childh = child.getMeasuredHeight();
mX += childw; //将每次子控件宽度进行统计叠加,如果大于设定的高度则需要换行,高度即Top坐标也需重新设置
Position position = new Position();
mLeft = getPosition(i - j, i);
mRight = mLeft + child.getMeasuredWidth();
if (mX >= mWidth) {
mX = childw;
mY += childh;
j = i;
mLeft = 0;
mRight = mLeft + child.getMeasuredWidth();
mTop = mY + 5;
//PS:如果发现高度还是有问题就得自己再细调了
}
mBottom = mTop + child.getMeasuredHeight();
mY = mTop; //每次的高度必须记录 否则控件会叠加到一起
position.left = mLeft;
position.top = mTop + 3;
position.right = mRight;
position.bottom = mBottom;
map.put(child, position);
}
setMeasuredDimension(mWidth, mBottom);
}
@Override
protected LayoutParams generateDefaultLayoutParams() {
return new LayoutParams(1, 1); // default of 1px spacing
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
int count = getChildCount();
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
Position pos = map.get(child);
if (pos != null) {
child.layout(pos.left, pos.top, pos.right, pos.bottom);
} else {
Log.i("MyLayout", "error");
}
}
}
private class Position {
int left, top, right, bottom;
}
public int getPosition(int IndexInRow, int childIndex) {
if (IndexInRow > 0) {
return getPosition(IndexInRow - 1, childIndex - 1)
+ getChildAt(childIndex - 1).getMeasuredWidth() + 8;
}
return getPaddingLeft();
}
}
3.将数据分别填充到左右两个控件中
这应该算是自动换行经典实例了吧,相信这个搞定以后同类型的需求都不成问题了。

阅读全文

与android写入文件换行相关的资料

热点内容
无线已加密不可上网是怎么了 浏览:464
什么app可以免费做手机 浏览:373
异性下载什么app 浏览:680
51单片机程序单步视频 浏览:239
家庭宽带如何连接服务器 浏览:117
汽车高压泵解压 浏览:770
上门正骨用什么app 浏览:758
安卓为什么免费使用 浏览:397
加密货币都有哪些平台 浏览:625
python和matlab难度 浏览:388
python爬虫很难学么 浏览:572
小米解压积木可以组成什么呢 浏览:816
为什么滴滴出行app还能用 浏览:564
怎么升级手机android 浏览:924
php权威编程pdf 浏览:996
扣扣加密技巧 浏览:722
苹果如何创建服务器错误 浏览:497
软考初级程序员大题分值 浏览:475
js压缩视频文件 浏览:580
linux如何通过命令创建文件 浏览:991