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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:14:35+00:00 2026-05-26T21:14:35+00:00

My code is : ListContacts.java public class ListContacts extends ListActivity { @Override public void

  • 0

enter image description here

My code is :

ListContacts.java

public class ListContacts extends ListActivity {
 @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    System.out.println("List Contacts : onCreate : ");

Cursor cursor = getContentResolver().query(
                ContactsContract.Contacts.CONTENT_URI, null,
                ContactsContract.Contacts.HAS_PHONE_NUMBER + " = 1", null,
                "UPPER(" + ContactsContract.Contacts.DISPLAY_NAME + ") ASC");

        startManagingCursor(cursor);

ImageCursorAdapter .java

public class ImageCursorAdapter extends SimpleCursorAdapter implements SectionIndexer{

public View getView(int pos, View inView, ViewGroup parent) {



        View v = inView;
        String phoneNumber = null;
        String contactID = null;

        // Associate the xml file for each row with the view
        if (v == null) {
        LayoutInflater inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = inflater.inflate(R.layout.contact_listview, null);

        }
        this.c.moveToPosition(pos);


  /**
         * Get the strings with the name and number of the person that the
         * current row
         */

        //
        String lName = this.c.getString(this.c
            .getColumnIndex(EMPLOYEE_NAME))


}



    }

listview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent" android:paddingLeft="5dp" android:paddingRight="5dp"
    android:layout_height="fill_parent" android:background="@drawable/listview_bac">


      <LinearLayout android:layout_width="fill_parent"
       android:layout_height="fill_parent" 
        android:layout_marginRight="4dp"       
         android:orientation="horizontal">

  <ImageView
        android:id="@+id/callimage" 
        android:layout_width="36dp"
        android:layout_height="49dp"
        android:clickable="true" 
        android:background="@android:color/transparent" 
         android:paddingRight="4dp"  
         android:src="@drawable/phone">
        </ImageView> 

     <LinearLayout android:layout_width="fill_parent"
      android:layout_height="wrap_content" 
       android:layout_gravity="center"     
         android:orientation="horizontal" >



         <TextView android:id="@+id/contact_name"
                android:textColor="@color/black"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ellipsize="marquee"
                android:textAppearance="?android:attr/textAppearanceLarge" 

                        />


            <ImageView
        android:id="@+id/favimage" 
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_gravity="top|right"
        android:background="@android:color/transparent" 
        android:src="@drawable/favorites" android:visibility="gone">
        </ImageView>




       <!--  <TextView android:id="@+id/contact_number"
                android:textColor="@color/black"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingTop="2dp"
                android:textAppearance="?android:attr/textAppearanceSmall"

        /> -->

        </LinearLayout>


        </LinearLayout>



</LinearLayout>

I need to change the image, color of textview of the listview on focus

  • 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-05-26T21:14:36+00:00Added an answer on May 26, 2026 at 9:14 pm

    Add an xml file to manage the background of the LinearLayout.

    list_bg_selector.xml :

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    
        <!-- Active tab -->
        <item android:state_selected="true" android:state_focused="false"
            android:state_pressed="false" android:drawable="@drawable/list_selected_bgimage" />
        <!-- Inactive tab -->
        <item android:state_selected="false" android:state_focused="false"
            android:state_pressed="false" android:drawable="@drawable/list_default_bgimage" />
        <!-- Pressed tab -->
        <item android:state_pressed="true" android:drawable="@drawable/list_selected_bgimage" />
        <!-- Selected tab (using d-pad) -->
        <item android:state_focused="true" android:state_selected="true"
            android:state_pressed="false" android:drawable="@drawable/list_selected_bgimage" />
    </selector> 
    

    To manage the text color, set the text color to another xml.

    text_selector.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    
        <item android:state_selected="true" android:color="@android:color/black"/>
        <item android:state_focused="true" android:color="@android:color/black"/>
        <item android:state_pressed="true" android:color="@android:color/black"/>
        <item android:color="@android:color/white"/>
    
    </selector>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code : ListContacts .java public class ListContacts extends ListActivity { @Override public void
Code: public interface IFoo { void Bar(); } public class FooClass : IFoo {
code structure @protocal A_Delegate { -(void)doIt:(BOOL)isDone; } Super Class A // has properties of
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
Code goes first: class A { public: ... int *foo() const { return _px;
Code: class Session extends Backbone.Model initialize: -> @bind 'change', @save console.log 'init' class SessionList
Code below defines a ChargeCustomer class that contains an array of type customers. I
Code snippet from here : void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char
Code snippet from here : void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char
Code: public ActionResult Create(Group group) { if (ModelState.IsValid) { group.int_CreatedBy = 1; group.dtm_CreatedDate =

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.