0

How can I convert from String[] to String only? So I can assign orderan to items and i can put it into my listview.

Here's my code.

MyClass class= new MyClass();

String orderan =class.getName();
String[] items = orderan; **the problem here

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, items);

        list.setAdapter(adapter);

3 Answers 3

1

It appears that you simply want this:

String orderan = class.getName();
String[] items = {orderan};

Or even:

String[] items = {class.getName()};
Sign up to request clarification or add additional context in comments.

Comments

0

ArrayAdapter wants an array, but you're trying to assign the string orderan into the array items. Instead, make a new array, and add orderran into it. Something like:

String[] items = new String[1];
items[0] = orderan;

Comments

0

You have to create an Array and add the string to it.

String[] items = new String[1];
items[0] = orderan;

you can do it in one line

String[] items = {orderan};

Comments

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.