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

  • Home
  • SEARCH
  • 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 8236843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:16:01+00:00 2026-06-07T19:16:01+00:00

Help me to avoid getting Unnecessary focus. I disabled focus, but I don’t know

  • 0

Help me to avoid getting Unnecessary focus. I disabled focus, but I don’t know how it’s getting focused. I suspect it’s due to expandable listView or customadapter. thanks in advance.

    ListDoctorsActivity.java

    public class ListDoctorsActivity extends ListActivity implements
        OnItemClickListener, OnClickListener {
    private ImageButton addUpdateButton;

    private DoctorAdapter doctorAdapter;
    private SimpleSectionAdapter<Doctor> sectionAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.at_list_doctors);

        // UI References
        addUpdateButton = (ImageButton) findViewById(R.id.add_update);

        // Set listener
        addUpdateButton.setOnClickListener(this);
        getListView().setOnItemClickListener(this);
    }

    private class DoctorAdapter extends ArrayAdapter<Doctor> {
        // Attributes
        private List<Doctor> doctors;
        private int expandedViewPosition = -1;

        public DoctorAdapter(Context context, int textViewResourceId,
                List<Doctor> doctors) {
            super(context, textViewResourceId, doctors);
            this.doctors = doctors;

        }

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

            if (view == null) {
                view = View.inflate(ListDoctorsActivity.this,
                        R.layout.at_list_item_doctor, null);

        holder = new Holder();
        holder.doctorNameTextView = (TextView) view
                        .findViewById(R.id.doctor_name);
        holder.specializationTextView = (TextView) view
                        .findViewById(R.id.specialization);
        holder.editImageButton = (ImageButton) view
                        .findViewById(R.id.edit);
        holder.expandableView =       view.findViewById(R.id.expandable_view);
        holder.callButton = (Button) view.findViewById(R.id.call);
        holder.emailButton = (Button) view.findViewById(R.id.email);
        holder.appointmentsButton = (Button) view
                        .findViewById(R.id.appointments);

                // Set properties
                holder.doctorNameTextView.setTypeface(headerTitleFont);

                view.setTag(holder);
            } else {
                holder = (Holder) view.getTag();
            }

            // Set properties
            final Doctor doctor = doctors.get(position);
            holder.doctorNameTextView.setText(doctor.getName());
            holder.specializationTextView.setText(doctor.getSpecialization());

            // Show / Hide the expandable view
            int visibility = position == expandedViewPosition ? View.VISIBLE
                    : View.GONE;
            holder.expandableView.setVisibility(visibility);
            // Event listeners
            OnClickListener clickListener = new OnClickListener() {

                @Override
                public void onClick(View v) {
                    switch (v.getId()) {
                    case R.id.edit:
                        edit(doctor);
                        break;
                    case R.id.call:
                        call(doctor);
                        break;
                    case R.id.email:
                        email(doctor);
                        break;
                    case R.id.appointments:
                        showAppointments(doctor);
                        break;
                    }
                }
            };

            holder.editImageButton.setOnClickListener(clickListener);
            holder.callButton.setOnClickListener(clickListener);
            holder.emailButton.setOnClickListener(clickListener);
            holder.appointmentsButton.setOnClickListener(clickListener);

            // Disable focus
            disableFocus(holder);

            return view;
        }

        private void disableFocus(Holder holder) {
            holder.editImageButton.setFocusable(false);
            holder.callButton.setFocusable(false);
            holder.emailButton.setFocusable(false);
            holder.appointmentsButton.setFocusable(false);
        }

        public void toggleExpandedView(int position) {
            expandedViewPosition = expandedViewPosition == position ? -1
                    : position;
            notifyDataSetChanged();
        }
    }

    static class Holder {
        public TextView doctorNameTextView;
        public TextView specializationTextView;
        public ImageButton editImageButton;
        public View expandableView;
        public Button callButton;
        public Button emailButton;
        public Button appointmentsButton;
    }

    class DoctorSectionizer implements Sectionizer<Doctor> {

        @Override
        public String getSectionTitleForItem(Doctor doctor) {
            return doctor.getName().toUpperCase().substring(0, 1);
        }
    }



    @Override
    protected void onStart() {
        super.onStart();
        // Model
        List<Doctor> doctors = Sorting(OrmanHelper.getDoctors());

        // Adapter
        doctorAdapter = new DoctorAdapter(this, R.layout.at_list_item_doctor,
                doctors);
        sectionAdapter = new SimpleSectionAdapter<Doctor>(this, doctorAdapter,
        R.layout.cmn_list_section, R.id.title, new   DoctorSectionizer());
        getListView().setAdapter(sectionAdapter);

    }

    @Override
    public void onItemClick(AdapterView<?> parentView, View view, int position,
            long id) {
        // Toggle list items
        int index = sectionAdapter.getIndexForPosition(position);
        doctorAdapter.toggleExpandedView(index);
        sectionAdapter.notifyDataSetChanged();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.add_update:
            Intent intent = new Intent(this, AddEditDoctorActivity.class);
            startActivity(intent);
            break;
        }
    }
    }

at_list_item_doctor.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:focusable="false" >

    <TextView
        android:id="@+id/doctor_name"
        style="@style/summary_text"
        android:layout_marginLeft="14dp"
        android:paddingTop="10dp"
        android:text="@string/name" />

    <TextView
        android:id="@+id/specialization"
        style="@style/medium_text"
        android:layout_below="@+id/doctor_name"a
        android:layout_alignLeft="@id/doctor_name"
        android:paddingBottom="10dp"
        android:textColor="@color/gray_darkest"
        android:text="@string/specialization" />

    <ImageButton
        android:id="@+id/edit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@id/doctor_name"
        android:layout_alignBottom="@id/specialization"
        android:focusable="false"
        android:background="@android:color/transparent"
        android:src="@drawable/edit" />

    <include
        android:id="@+id/expandable_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/specialization"
        android:visibility="gone"
        layout="@layout/at_list_item_expandable_doctor" />

</RelativeLayout>
  • 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-07T19:16:02+00:00Added an answer on June 7, 2026 at 7:16 pm

    Best Idea is just Request Focus to any one Textview in List Item row,

    Something like,

    <TextView
            android:id="@+id/doctor_name"
            style="@style/summary_text"
            android:layout_marginLeft="14dp"
            android:paddingTop="10dp"
            android:text="@string/name" 
    
    <requestFocus />
    />
    

    OR by Programatically, in Adapter class ‘s getView()

    holder.doctorNameTextView.requestFocus(); // Code for understanding
    

    Try this and let me know whether it works or not.

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

Sidebar

Related Questions

how string.format() can help to avoid using + in such statement: string statement =
A popular editor uses highlighting to help programmers avoid using C++ keywords in Java.
Help! I'm using the ASP.Net Login control on a Login page, but the Login
I'm trying to update my database table with PDO, but to avoid security leaks,
I'm new to RequestFactory but with generous help of Thomas Broyer and after reviewing
I'm getting a syntax error while using the code below. it suppoused to avoid
Can I get some help, I am trying to avoid dynamic sql, the dynamic
This is potentially a simple question but I wanted to ask to avoid running
I am use OpenHttpConnection(URL) method to connect internet in my android application. But getting
Help me translate following block of the Haskell code. The run function produces text

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.