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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:53:38+00:00 2026-06-09T20:53:38+00:00

I have some trouble with layout in my list activity. My list contain separators

  • 0

I have some trouble with layout in my list activity.
My list contain separators and text rows

SetupActivity extend ListActivity

private MyCustomAdapter mAdapter;
TextView selection;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    mAdapter = new MyCustomAdapter();

    mAdapter.addItem("Help/FAQ");
    mAdapter.addSeparatorItem("Connection to Server");
    // mAdapter.addItem("Connection");
    // mAdapter.addItem("Network");
    // mAdapter.addItem("config");
    // mAdapter.addItem("User");
    // mAdapter.addItem("pass");
    // mAdapter.addItem("Email");
    // mAdapter.addItem("PlatForm");
    mAdapter.addSeparatorItem("Consumption");
    // mAdapter.addItem("100%");
    mAdapter.addSeparatorItem("Map");
    // mAdapter.addItem("Map rotation");
    // mAdapter.addItem("auto Zoom");
    // mAdapter.addItem("Measure Units");
    // mAdapter.addItem("Show Heading");
    // mAdapter.addItem("Compass North");*/
    mAdapter.addFooterItem(getString(R.string.setup_note_map));
    mAdapter.addSeparatorItem("Support");
    mAdapter.addItem("About");
    /*
     * mAdapter.addItem("Contact Us"); mAdapter.addItem("Tutorial");
     * mAdapter.addItem("Setup Wizard");
     */
    mAdapter.addSeparatorItem("Blogs");
    mAdapter.addFooterItem(getString(R.string.setup_note_blogs));

    setListAdapter(mAdapter);

    // selection = (TextView) findViewById(R.id.text);
}

public void onListItemClick(ListView parent, View view, int position,
        long id) {
    parent.getChildAt(position).setBackgroundColor(position);
    if (position == 0) {
        Intent myIntent = new Intent(SetupActivity.this,
                WebviewHandlerActivity.class);
        myIntent.putExtra("ressource", "help");
        SetupActivity.this.startActivity(myIntent);
    } else if (position == 6) {
        Intent myIntent = new Intent(SetupActivity.this,
                AboutActivity.class);
        SetupActivity.this.startActivity(myIntent);
    }

}

// Adapter Class
private class MyCustomAdapter extends BaseAdapter {

    private static final int TYPE_ITEM = 2;
    private static final int TYPE_SEPARATOR = 0;
    private static final int TYPE_FOOTER = 1;
    private static final int TYPE_MAX_COUNT = TYPE_ITEM + 1;

    private ArrayList<String> mData = new ArrayList<String>();
    private LayoutInflater mInflater;

    private TreeSet<Integer> mSeparatorsSet = new TreeSet<Integer>();

    private TreeSet<Integer> mFooterSet = new TreeSet<Integer>();

    public MyCustomAdapter() {
        getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public void addItem(final String item) {
        mData.add(item);
        notifyDataSetChanged();
    }

    public void addSeparatorItem(final String item) {
        mData.add(item);
        // save separator position
        mSeparatorsSet.add(mData.size() - 1);
        notifyDataSetChanged();
    }

    public void addFooterItem(final String item) {
        mData.add(item);
        // save separator position
        mFooterSet.add(mData.size() - 1);
        notifyDataSetChanged();
    }

    @Override
    public int getItemViewType(int position) {
        if (mSeparatorsSet.contains(position))
            return TYPE_SEPARATOR;
        else if (mFooterSet.contains(position))
            return TYPE_FOOTER;
        return TYPE_ITEM;
    }

    @Override
    public int getViewTypeCount() {
        return TYPE_MAX_COUNT;
    }

    public int getCount() {
        return mData.size();
    }

    public String getItem(int position) {
        return mData.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        int type = getItemViewType(position);
        if (convertView == null) {
            holder = new ViewHolder();
            switch (type) {
            case TYPE_ITEM:
                convertView = mInflater.inflate(R.layout.item1, null);
                holder.textView = (TextView) convertView
                        .findViewById(R.id.text);
                break;
            case TYPE_SEPARATOR:
                convertView = mInflater.inflate(R.layout.item2, null);
                holder.textView = (TextView) convertView
                        .findViewById(R.id.textSeparator);
                break;
            case TYPE_FOOTER:
                convertView = mInflater.inflate(R.layout.footer, null);
                holder.textView = (TextView) convertView
                        .findViewById(R.id.note);
                break;
            }
            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.textView.setText(mData.get(position));
        return convertView;
    }

}

public static class ViewHolder {
    public TextView textView;
}

my xml item1 & item2 contain a LinearLayout with a TextView inside
and my footer.xml only a textView

My problem is when i click on a row it doesn’t get orange to say that i clicked on it except my footer…(the one i don’t want)

So i figure out it’s because it’s not in a LinearLayout so i tried to put off the LinearLayout of item1.xml but i can’t compile anymore.

Does someone can explain to me how to get my row with the click Animation and not on my footers ?

Cheers

  • 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-09T20:53:39+00:00Added an answer on June 9, 2026 at 8:53 pm

    You are not getting clicked color because you have set a background color `

    setBackgroundColor

    You need to set a statelistDrawable as background

    Edit: You need to set a drwable something like this

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@drawable/pressed_img" android:state_pressed="true"/>
        <item android:drawable="@drawable/default_img"/>   
    </selector>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some trouble with using h:selectOneRadio . I have a list of
I defined a new Activity on my project and I have some trouble with
I have some trouble when I try to map object to int . My
I have some trouble with my trac installation (version 11.4). What should I do
I have some trouble with jquery ui-events: In my application, there are some sliders.
I have some trouble achieving adequate real-time performance from my application and wondering if
i seem to have some trouble installing autopy.h https://github.com/msanders/autopy/#introduction i already tried the installation
I'm have some trouble with the fulltext CONTAINS operator. Here's a quick script to
I am mlearning javascript and have some trouble creating an onject via prototype. I
I'm training with Azure environment and I have some trouble with the object CloudDriver

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.