0

Here is my Array :

  String[] details={
            "Sharab se bacho isiliye kyunki wo har burayi ki chabi hai.❞\n        Allah ke Rasool (ﷺ)" +
                    "(Hadith: Mustadrak: 7313)",
            "‟Tum ek doosre ko taana na diya karo aur naa ek doosre ko bure naamo se pukaaro.’\n" +
                    " Surah Al-Hujurat 49:11",
            "❝ Ramzan ka wo Mahina jis me Quraan ka Nuzool hua saari Insaniyat ki Hidayat aur Rahnumai ke liye.❞\n" +
                    " Surah Baqrah 2:185",
            "Rasool’Allah (Sallallahu Alaihay Wasallam) Ne Irshaad Farmaya –\n" +
                    "“Yakinan Woh Shakhs Kamiyab Ho Gaya Jisne Apne Dil Ko Imaan Ke Liye Khalis Kar Liya" +
                    "Aur Apne Dil Ko Paak Kar Liya \n     – (Musnad Ahmad : 5/147)",
            "Aye Nabi (Salallahu Alaihi Wassalam)! Aap Keh dijiye, Agar Allah Ta’ala Masi Ibn Mariyam aur Uski Walida aur tamam Zameen walo ko Halaq karna chahe to kiski majaal hai ke Usko is iraade se rok ley.. \n     Quran 5:17)",

This is how I created the List of a ModelClass :

 List<ToggleModel> toggleModelList;
 toggleModelList.add(new ToggleModel("dsds"));

How can I pass the entire details array in this List and not Individually doing toggleModelList.add("Value1") etc..

1 Answer 1

2

You can convert arrays to list like following

List<String> list = Arrays.asList(details);

For array of model classes

List<POJO> list = new ArrayList<POJO>(Arrays.asList(details));
Sign up to request clarification or add additional context in comments.

9 Comments

how to do the same with a List of a Model Class ?
Updated the post. accept the answer if it's solving your issue.
Nope , not Working
because you are passing a string array
if you have a string array then use this List<String> list = Arrays.asList(details);
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.