Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8026969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:39:41+00:00 2026-06-04T23:39:41+00:00

I went to the main.xml to the Graphical Layout and dragged over to the

  • 0

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:

<ExpandableListView
        android:id="@+id/expandableListView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ExpandableListView>

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.

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<String> itemsList;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        itemsList = new ArrayList<String>();
        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);
    }
}

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.

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 ?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:39:44+00:00Added an answer on June 4, 2026 at 11:39 pm

    You can use “Adapters” for that which can be ArrayAdapte/BaseAdapter/CursorAdapter
    ,,,a simple example using array adapter could be

    public class YourActivity extends Activity 
    {
        private ListView lv;
        public void onCreate(Bundle saveInstanceState) {
             lv = (ListView) findViewById(R.id.your_list_view_id);
             // Instanciating an array list (you don't need to do this, you already have yours)
             ArrayList<String> your_array_list = new ArrayList<String>();
             your_array_list.add("foo");
             your_array_list.add("bar");
             // This is the array adapter, it takes the context of the activity as a first // parameter, the type of list view as a second parameter and your array as a third parameter
             ArrayAdapter<String> arrayAdapter =      
             new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, your_array_list);
             lv.setAdapter(arrayAdapter); 
             setContentView(R.layout.your_layout);
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I went to Twitter's resource page here (https://twitter.com/about/resources/tweetbutton) and got the following code: <a
I went as far as searching C sources, but I can't find this function,
I have the following code that loads an XML file into a datatable (I
I am using lxml to read my xml file. I am using a code
I went about with the following code to detect the long argument to a
I'm having trouble understanding where I went wrong with my code: #include <iostream> #include
I have the following code: class Program { static void Main(string[] args) { string
Disclaimer: I've went over many examples and read the docs. This question entails 3
My question is pretty simple. I'm parsing an XML and the parsing procedure went
Hi I try to customize a seekbar. Here's my Problem: main.xml ... <SeekBar android:id=@+id/seekBar1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.