Reputation: 195
private String[] questions = {"1. Java was invented in 1222",
"2. Constructor overloading is not possible in Java",
"3. Assignment operator is evaluated Left to Right.",
"4. Variable name can begin with a letter, \"$\", or \"_\"",
"5. Interfaces can be instantiated",
"6. A .class file contains bytecodes?",
"7. James Gosling is father of Java?",
"8. Objects of a subclass can be assigned to a super class reference.",
"9. Is java a programming language?",
"10. java is only Interpreted"};
this is String[] of questions
textView2 = findViewById(R.id.textView2);
int index = 0;
textView2.setText(questions[index]);
when I use setText on TextView, and try to set questions index 0 string Result
Only 1st Character is set by this, please tell me if there is any problem in this code
<TextView android:id="@+id/textView2" android:layout_width="10dp" android:layout_height="18dp" android:layout_marginBottom="73dp" android:textSize="18sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.498" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.521" />
Upvotes: 0
Views: 61
Reputation: 370
As per the xml that you have posted it looks like the width is not correct.
<TextView android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_marginBottom="73dp"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.521" />
You have provided 10dp as width for your text view and that is why it is not able to show you the entire content. Changing this to wrap_content
or match_parent
will fix it.
Upvotes: 2