I am totally new to Android Studio with Java, I am familiar only with html , CSS , JavaScript and PHP.
I am building an app and I need it to generate a list of items from an array. How do I do that?
I tried to do simply this, but nothing shows up in the activity!
public void view(View v){
TextView t = new TextView(viewAuto.this);
t.setTextColor(Color.RED);
t.setText("PIPPO");
}
2
Answers
in Android, in the first step, you put each feature of the palette in xml, you have to identify it in java files
like this
TextView textView = findViewById(R.id.textView);
Then you can apply the changes
What you did was to create an object from textView, which is wrong in the case of material design
Rather, it applies to classes, fragments, adapters, etc
You need first create XML layout and create TextView component there
then you go code and get text view, and append all the strings using n so that at the end of each string it goes to new line
For showing your items in a scrollable list, you need to use
ScrollView
, for better performance you need to useRecyclerView