Я уже знаю, что этот вопрос задан раньше, но ни одно из решений, похоже, не работает для меня.Текст textView остается в одной строке
Внутри srollView У меня есть таблица, в которой я добавляю три столбца в последней ячейке каждой строки. У меня есть большой текст, который должен автоматически форматироваться в многострочном формате, но текст остается в одной строке, выходящей из экрана.
вопрос: как я могу установить из кода текст, который нужно сломать, когда он достигнет конца экрана?
Вот мой код:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/buttons_up_system_storical_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="left"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_system_to_technical_part"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Parte tecnica" />
<Button
android:id="@+id/btn_system_to_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="Descrizione" />
<Button
android:id="@+id/btn_system_to_ticket"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/btn_system_to_description"
android:layout_alignParentTop="true"
android:text="Vai a ticket" />
<Button
android:id="@+id/btn_system_new_report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/btn_system_to_technical_part"
android:text="Nuovo rapporto" />
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/scroll_view_system_description"
android:layout_below="@+id/buttons_up_system_storical_layout" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="*"
android:id="@+id/tl_system_storical"
>
</TableLayout>
</FrameLayout>
</ScrollView>
</RelativeLayout>
код:
public class SystemStoricalActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_system_storical);
Context context=this;
TableLayout tlSystemStorical= (TableLayout) findViewById(R.id.tl_system_storical);
TableRow tr_head = new TableRow(this);
Button btnSystemToDescription = (Button) findViewById(R.id.btn_system_to_description);
Button btnSystemNewReport = (Button) findViewById(R.id.btn_system_new_report);
Button btnSystemToTicket = (Button) findViewById(R.id.btn_system_to_ticket);
Button btnSystemToTechnicalPart = (Button) findViewById(R.id.btn_system_to_technical_part);
Bundle extras = getIntent().getExtras();
String s=null;
if (extras != null) {
s = extras.getString("ticket_from_system");
}
final Customer[] customers = new Customer.Provider(context).searchBySystemIdOrCompanyName(s);
Customer c= customers[0];
ngs.ariesmobile.data.System[] a = new ngs.ariesmobile.data.System.Provider(context).findByCustomer(c);
ngs.ariesmobile.data.Report[] reportList= new ngs.ariesmobile.data.Report.Provider(context).findByCustomer(c);
tr_head.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
tr_head.setBackgroundColor(Color.rgb(0, 230, 230));
TextView lblSystemStoricalHeaderId = new TextView(this);
lblSystemStoricalHeaderId.setText("ID ");
tr_head.addView(lblSystemStoricalHeaderId);
TextView lblSystemStoricalHeaderData = new TextView(this);
lblSystemStoricalHeaderData.setText("Data");
tr_head.addView(lblSystemStoricalHeaderData);
TextView lblSystemStoricalHeaderDescription = new TextView(this);
lblSystemStoricalHeaderDescription.setText(" Descrizione");
tr_head.addView(lblSystemStoricalHeaderDescription);
tr_head.setMinimumHeight(30);
tlSystemStorical.addView(tr_head, new TableLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
for(int i=0;i<reportList.length;i++){
TableRow tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
TextView lblSystemStoricalId = new TextView(this);
lblSystemStoricalId.setText(" "+reportList[i].getId()+" | ");
tr.addView(lblSystemStoricalId);
TextView lblSystemStoricalData = new TextView(this);
long dataC = reportList[i].getDate()*1000;
java.util.Date df = new java.util.Date(dataC);
String vv = new SimpleDateFormat("dd/MM/yyyy").format(df);
lblSystemStoricalData.setText(vv);
tr.addView(lblSystemStoricalData);
TextView lblSystemStoricalDescription = new TextView(this);
lblSystemStoricalDescription.setText(" | "+reportList[i].getReportDescription());
tr.addView(lblSystemStoricalDescription);
tr.setBackgroundResource(R.drawable.border);
tr.setMinimumHeight(40);
tlSystemStorical.addView(tr, new TableLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
}
btnSystemToDescription.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Bundle si=getIntent().getExtras();
String s=si.getString("ticket_from_system");
Intent intent = new Intent(getApplicationContext(), SystemActivity.class);
intent.putExtra("ticket_from_system",s);
startActivity(intent);
}
});
btnSystemNewReport.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Bundle si=getIntent().getExtras();
String s=si.getString("ticket_from_system");
Intent intent = new Intent(getApplicationContext(),ReportCustomerActivity.class);
intent.putExtra("report_from_system",s);
startActivity(intent);
}
});
btnSystemToTicket.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Bundle si=getIntent().getExtras();
String s=si.getString("ticket_from_system");
Intent intent = new Intent(getApplicationContext(), TicketListActivity.class);
intent.putExtra("ticket_from_system",s);
startActivity(intent);
}
});
btnSystemToTechnicalPart.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Bundle si=getIntent().getExtras();
String s=si.getString("ticket_from_system");
Intent intent = new Intent(getApplicationContext(), SystemTechnicalPartActivity.class);
intent.putExtra("ticket_from_system",s);
startActivity(intent);
}
});
}
}
Это сработало спасибо :) – Inoshichi
Замечательно! Работает ли кнопка ответа accept? ;-) –