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 6581865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:12:29+00:00 2026-05-25T16:12:29+00:00

here is my code… package sortarray.com; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os.Bundle;

  • 0

here is my code…

package sortarray.com;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class SortArray extends Activity {
    ArrayList<String[]> matchedFruits = new ArrayList<String[]>();
TextView selection;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    String fruits[] = new String[7];//Sorted array
    fruits[0] = "apple";
    fruits[1] = "capricot";
    fruits[2] = "banana";
    fruits[3] = "mango";
    fruits[4] = "melon";
    fruits[5] = "pineapple";
    fruits[6] = "peach";
    char currChar=fruits[0].charAt(0);//Get first char of first element

    boolean match=false;
    int len=fruits.length;
    List<String> tmp = new ArrayList<String>();

    for(int i=1;i<len;i++)
    {
    Log.d("Comparing ", fruits[i].charAt(0)+","+currChar);
    if (fruits[i].charAt(0)==currChar)
    {
    if (match==false)//new match?
    {
    match=true;//Reset search
    tmp.clear();//clear existing items
    tmp.add(fruits[i-1]);
    Log.d("Started new list ", fruits[i-1]);
    }
    else
    {
    tmp.add(fruits[i-1]);
    Log.d("Added to list ", fruits[i-1]);
    }
    }
    else
    {
    match=false;
    tmp.add(fruits[i-1]);
    matchedFruits.add(tmp.toArray(new String[tmp.size()]));//add to final list
    Log.d("Finished a list ", fruits[i-1]);
    tmp.clear();//clear existing items

    }
    currChar=fruits[i].charAt(0);


    }
    tmp.add(fruits[len-1]);
    matchedFruits.add(tmp.toArray(new String[tmp.size()]));//add left over items
    printList();
    }

    void printList()
    {
    //Print the list 
    for(int i=0;i<matchedFruits.size();i++)
    {
    String tmp2[]= matchedFruits.get(i);
    for (int j=0;j<tmp2.length;j++)
    {
     //Log.d("Final list", "Array #"+i+"["+j+"],"+tmp2[j]);
        **//selection.setText(tmp2[j].toString());**
    }
    }
    }

    }

i want to print the output of string
using the selection.setText(); // selection.setText(tmp2[j].toString());**
but not able to do so….

plz help me..

  • 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-05-25T16:12:29+00:00Added an answer on May 25, 2026 at 4:12 pm

    You have to bind your textView in your java code with one in your R.layout.main.

    In layout, main.xml :

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/tv"
        />
    </LinearLayout>
    

    In java :

    TextView selection = (TextView) findViewById(R.id.tv);
    String mssg;
    for (int j=0;j<tmp2.length;j++)
    {
        mssg += tmp2[j].toString());
    }
    
    selection.setText(mssg);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

See here: http://code.google.com/p/ie7-js/ Does anyone have any experience or remarks about this javascript? Is
JAVA Code Here is some part of my code that I have written in
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code from MSDN . I don't understand why the work isn't just
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
enter code here I have a table on SQL server 2005 with bigint primary
The code here is X++. I know very little about it, though I am
enter code here Hi All, I have a simple windows service application that connects
Edit: The code here still has some bugs in it, and it could do
I have this code here: var infiltrationResult; while(thisOption) { var trNode = document.createElement('tr'); var

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.