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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:47:06+00:00 2026-06-09T05:47:06+00:00

I am using a ListView with a custom row wich has 2 TextViews. I

  • 0

I am using a ListView with a custom row wich has 2 TextViews. I have made my own Adapter and it’s working fine with my list. Now, I want the user to input 2 texts and then insert a new row (with user’s inputs) in my ListView. I’ve tried with add method but I’m getting UnsupportedOperationException. Do I have to override add method also? if so, what do I need to do in it? Thank you.

I’m going to paste a fragment of the code. Let me know if you need further information.

public class ChatAdapter extends ArrayAdapter<ChatItems>{

Context context;
int textViewResourceId;
ChatItems[] objects;


public ChatAdapter(Context context, int textViewResourceId,
        ChatItems[] objects) {
    super(context, textViewResourceId, objects);

    this.context = context;
    this.textViewResourceId = textViewResourceId;
    this.objects = objects;
}


@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    ChatHolder holder = null;


    if(row == null){
    LayoutInflater inflater =  ((Activity)context).getLayoutInflater();
    row = inflater.inflate(textViewResourceId, null);

    holder = new ChatHolder();
    holder.user = (TextView) row.findViewById(R.id.textUser);
    holder.msg = (TextView) row.findViewById(R.id.textText);

    row.setTag(holder);

    }else
        holder = (ChatHolder) row.getTag();


    ChatItems items = objects[position];
    holder.msg.setText(items.msg);
    holder.user.setText(items.user);


    return row;

}
static class ChatHolder{
    TextView user;
    TextView msg;
}

}

public class ChatItems {

String user;
String msg;

public ChatItems(String user, String msg){
    this.user = user;
    this.msg = msg;
}

}

  • 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-09T05:47:08+00:00Added an answer on June 9, 2026 at 5:47 am

    If you want to add another items to your ArrayAdapter use ArrayList instead of Array as your back-end data holder. If you are using Array, than ArrayAdapter will use List internally which can’t be modified later.

    Remove objects field from your ChatAdapter.

    Rewrite your constructor like

    public ChatAdapter(Context context, int textViewResourceId, List<ChatItems> objects) {
        super(context, textViewResourceId, objects);
        this.context = context;
        this.textViewResourceId = textViewResourceId;
    }
    

    to get the item in getView() use ChatItems items = getItem(position) instead of ChatItems items = objects[position];

    And finally create your adapter like adapter = new ChatAdapter(this, R.layout.chat_item, new ArrayList<ChatItems>());

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom listview using adapter. Each row of the list view
I have three textviews in a row of a listview using custom adapter and
HI Guyz i have created a sectioned custom listview using baseadapter its working fine
We have created custom listview by using the Base adapter. List view contains Text
I have a listView using a custom adapter. Each row contains a button and
So I have a custom ListView object. The list items have two textviews stacked
I'm using a custom ListView which has several TextView objects in each row. in
i have a ListView with a custom Servizio object in every row. I'm using
I have made a custom listView which which extends ListActivity and each row contains
I am using an array list, a listView, and a custom simple adapter in

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.