1

I've succesfully figured out how to get my soap object in memory. Now i'm trying to get what I've returned into a ListView.

My Custom Class looks like this

public class JudgmentInformationClass {
    public static class PipelineGridViewClass {
        private String CaseId;
        private double Amount;
        private String CaseDescription;
        private Date JudgmentDate;
    }
}

This returns exactly what i'm looking for 10 rows of this information.

Now I want to send it to a basic listview.

I have a custom List working but i cannot figure out how to make my custom arraylist. I get the following error.

Error:(103, 53) error: no suitable constructor found for ArrayAdapter(MainActivity,int,ArrayList<PipelineGridViewClass>)
constructor ArrayAdapter.ArrayAdapter(Context,int,int,List<String>) is not applicable
(actual and formal argument lists differ in length)
constructor ArrayAdapter.ArrayAdapter(Context,int,List<String>) is not applicable
(actual argument ArrayList<PipelineGridViewClass> cannot be converted to List<String> by method invocation conversion)
constructor ArrayAdapter.ArrayAdapter(Context,int,int,String[]) is not applicable
(actual and formal argument lists differ in length)
constructor ArrayAdapter.ArrayAdapter(Context,int,String[]) is not applicable
(actual argument ArrayList<PipelineGridViewClass> cannot be converted to String[] by method invocation conversion)
constructor ArrayAdapter.ArrayAdapter(Context,int,int) is not applicable
(actual argument ArrayList<PipelineGridViewClass> cannot be converted to int by method invocation conversion)
constructor ArrayAdapter.ArrayAdapter(Context,int) is not applicable
(actual and formal argument lists differ in length)

.

 private void SetListView(Activity activity) {

    activity.runOnUiThread(new Runnable() {
        public void run() {
            ArrayList<JudgmentInformationClass.PipelineGridViewClass> pipelineview = JudgmentInformationClass.PipelineGridViewClass.PipelineGridView();
            //ArrayList<JudgmentInformationClass.PipelineGridView>
            lv = (ListView) findViewById(R.id.listview);
            /*List<String> your_array_list = new ArrayList<String>();
            your_array_list.add("foo");
            your_array_list.add("bar");*/
            ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
                    MainActivity.this,
                    android.R.layout.simple_list_item_1,
                    pipelineview);

            lv.setAdapter(arrayAdapter);
        }
    });
}
1
  • Where do you call setListView()? Commented Feb 14, 2016 at 20:26

1 Answer 1

1

You can't use the ArrayAdapter in this way.

Since you are declaring ArrayAdapter<String> arrayAdapter you can't use a constructor with

ArrayAdapter(MainActivity,int,ArrayList<PipelineGridViewClass>)

It is the reason of your issue:

Error:(103, 53) error: no suitable constructor found for ArrayAdapter(MainActivity,int,ArrayList) constructor ArrayAdapter.ArrayAdapter(Context,int,int,List) is not applicable

You can use somenthing like this:

 ArrayAdapter<PipelineGridViewClass> arrayAdapter = new ArrayAdapter<PipelineGridViewClass>(
                    MainActivity.this,
                    android.R.layout.simple_list_item_1,
                    pipelineview);

Pay attention to the doc:

However the TextView is referenced, it will be filled with the toString() of each object in the array. You can add lists or arrays of custom objects. Override the toString() method of your objects to determine what text will be displayed for the item in the list.

It means that you have to override the toString() of your PipelineGridViewClass class.

Sign up to request clarification or add additional context in comments.

8 Comments

@JoshuaLong Mark the answer if it resolves your issue. It can help other users. For the emulator if you need any help I suggest you asking a new question. Other user will help you.
Gabriele, I'm just complaining. The list view is populating, however it's not populating with my class objects it's populated with classname@id
@JoshuaLong I have updated the answer. You need to override the toString method in your custom class
Gabriele, thanks for the tip. I want to @ your name but SO isn't allowing me. I'm confused. I need to override the toString() even though I can see my ArrayList objects populated with the correct data?
@JoshuaLong No, of course you have to ovveride the method only to change the default output. (For example you don't need to override if you are using strings)
|

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.