Java Android TextView,项目数量有限,功能特殊
我想要一个多行文本视图,并向其中添加文本 在文本视图中添加五行之后,我想开始添加到文本视图的开头 例如:(数字作为文本),1,2,3,4,5->6,2,3,4,5->6,7,3,4,5等等 我曾考虑过使用StringBuilder,但没有找到一种有效的方法来实现这一点 每行的分隔符为“\n\n”,这可能有助于解决此问题 或者我应该只做5个文本视图,并在它们之间设置一些切换框 按钮xml:Java Android TextView,项目数量有限,功能特殊,java,android,textview,Java,Android,Textview,我想要一个多行文本视图,并向其中添加文本 在文本视图中添加五行之后,我想开始添加到文本视图的开头 例如:(数字作为文本),1,2,3,4,5->6,2,3,4,5->6,7,3,4,5等等 我曾考虑过使用StringBuilder,但没有找到一种有效的方法来实现这一点 每行的分隔符为“\n\n”,这可能有助于解决此问题 或者我应该只做5个文本视图,并在它们之间设置一些切换框 按钮xml: <TextView android:id="@+id/searchesInputTextVie
<TextView
android:id="@+id/searchesInputTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollHorizontally="false"
android:width="300dp"
android:height="200dp"
android:background="@drawable/border_style"
android:maxLines="5"
android:layout_marginTop="24dp"
/>
你能给我看看你的一些代码吗???@DixitPanchal我添加了一些代码,希望它能清晰一点。
public class MainActivity extends AppCompatActivity {
private TextView searchesTextView;
private ImageButton refreshCurrentLocationButton;
private String myText = "";
refreshCurrentLocationButton = (ImageButton) findViewById(R.id.currentLocationRefreshImageButton);
searchesTextView = (TextView) findViewById(R.id.searchesInputTextView);
refreshCurrentLocationButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Actual code
myText += location.ToString() + "\n\n";
searchesTextView.setText(myText);
});
}