Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How i can create a ListView from a Selection

  1. #1

    Default How i can create a ListView from a Selection

    Hi, im trying to create a listview from a selection of a AutoCompleteTextView

    here's my code

    final AutoCompleteTextView editText = findViewById(R.id.actv);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, names);
    editText.setAdapter(adapter);

    editText.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    // select ACTV (AutoCompleteTextView)
    String authorPicked = parent.getItemAtPosition(position).toString();
    final List<News> escritor = articlesProvider.getArticlesByAuthorName(authorPic ked);

    Toast toast = Toast.makeText(getApplicationContext(), authorPicked, Toast.LENGTH_SHORT);
    toast.show();

    ArrayList<String> articulos = new ArrayList<>();
    for(Article author : escritor) {
    frases.add(author.getArticle());

    }

    ListView myList;
    myList = findViewById(R.id.ListView1);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, articulos);
    myList.setAdapter(adapter);

    }
    });

    but with this i don't get results if i print the value of
    Log.d("Valor: ","Contiene " + escritor);
    i get [] as result

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How i can create a ListView from a Selection

    get [] as result
    That shows an empty list.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:


  4. #3

    Default Re: How i can create a ListView from a Selection

    yes norm, thanks i already fix the problem yesterday

  5. The Following User Says Thank You to ericjk21 For This Useful Post:


Similar Threads

  1. Removing from a ListView w/ PopupMenu
    By ProgrammablePeter in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 15th, 2014, 01:35 PM
  2. Android Eclipse: Populate the ListView with dynamic Array
    By chevy in forum Android Development
    Replies: 4
    Last Post: April 18th, 2014, 07:42 PM
  3. How to center ListView text
    By RaiOh in forum Android Development
    Replies: 0
    Last Post: February 16th, 2014, 02:42 PM
  4. Help with Course Selection
    By randy81 in forum The Cafe
    Replies: 4
    Last Post: August 14th, 2013, 03:51 AM
  5. Replies: 1
    Last Post: March 21st, 2013, 08:51 AM