HomejavaarrayList in android studio arrayList in android studio 0 Ankit Rawat May 14, 2021 agar aap iss tarike ka layout banana chate hai to iss necche diye hue code ko simple copy paste kardo same asha design bann jayegaoutput xml file code java file code package com.example.ankitmavockapp; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.LinearLayout; import android.widget.TextView; import java.util.ArrayList; public class ColorsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_colors); ArrayList words = new ArrayList(); words.add("one"); words.add("two"); words.add("three"); words.add("four"); words.add("five"); words.add("six"); words.add("seven"); words.add("eight"); words.add("nine"); words.add("ten"); LinearLayout rootView = (LinearLayout) findViewById(R.id.rootColor); for(int index = 0; index < words.size();index++) { TextView wordsView = new TextView(this); wordsView.setText(words.get(index)); rootView.addView(wordsView); } } } Tags java Newer Older
if you have any doubts please let me know