Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i add an arrayList type of string to a ListView in Eclipse Android?
    primarykey
    data
    text
    <p>I went to the main.xml to the Graphical Layout and dragged over to the designer a ExpandableList . I can see it also in the main.xml runtime code:</p> <pre><code>&lt;ExpandableListView android:id="@+id/expandableListView1" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;/ExpandableListView&gt; </code></pre> <p>But when im running my application i dont see it in the android device. What i want to do is to add arrayList string to this ListView so i can select from this list in my device.</p> <pre><code>package com.testotspeech; import java.util.ArrayList; import java.util.Arrays; import java.util.Locale; import android.app.Activity; import android.os.Bundle; import android.speech.tts.TextToSpeech; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; public class AndroidTestToSpeechActivity extends Activity implements TextToSpeech.OnInitListener { /** Called when the activity is first created. */ private TextToSpeech tts; private Button btnSpeak; private EditText txtText; private ListView lview; private ArrayList&lt;String&gt; itemsList; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); itemsList = new ArrayList&lt;String&gt;(); Log.i("----------",Arrays.toString(Locale.getAvailableLocales())); itemsList.add(Arrays.toString(Locale.getAvailableLocales())); tts = new TextToSpeech(this, this); btnSpeak = (Button) findViewById(R.id.btnSpeak); lview = (ListView) findViewById(R.id.expandableListView1); txtText = (EditText) findViewById(R.id.txtText); // button on click event btnSpeak.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { speakOut(); } }); } @Override public void onDestroy() { // Don't forget to shutdown tts! if (tts != null) { tts.stop(); tts.shutdown(); } super.onDestroy(); } public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.ENGLISH); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e("TTS", "This Language is not supported"); } else { btnSpeak.setEnabled(true); speakOut(); } } else { Log.e("TTS", "Initilization Failed!"); } } private void speakOut() { String text = txtText.getText().toString(); tts.speak(text, TextToSpeech.QUEUE_FLUSH, null); } } </code></pre> <p>I have a Log.i and then under it ihave itemsList wich is ArrayList Im getting a list of available languages in my Device. I want to add this list to the ListView so i can select from there the language in my device and it will change the language in real time. </p> <p>The problem is that i dont see the ListView at all when running the application on my device and second problem is how to add the list to the ListView ?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload