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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:43:21+00:00 2026-06-08T18:43:21+00:00

Below is my layout: <EditText android:id=@+id/account_et android:layout_width=match_parent android:layout_height=fill_parent android:layout_weight=1 android:drawableRight=@drawable/icon_backall android:ems=10 android:hint=@string/str_md_email android:inputType=textEmailAddress android:padding=10dp

  • 0

Below is my layout:

<EditText
android:id="@+id/account_et"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:drawableRight="@drawable/icon_backall"
android:ems="10"
android:hint="@string/str_md_email"
android:inputType="textEmailAddress"
android:padding="10dp" >
</EditText>

I want to show the drawableRight when EditText be focused.
And hide while without focus.
Another one is that I want to set OnClickListener of drawableRight.
How can I do?

  • 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-08T18:43:22+00:00Added an answer on June 8, 2026 at 6:43 pm

    I hope my sample will help you

    activity_main.xml
    
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="130dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:inputType="textEmailAddress" >
        </EditText>
    
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="14dp"
            android:layout_marginTop="43dp"
            android:src="@drawable/ic_launcher"
            android:visibility="invisible" >
        </ImageView>
    
        <EditText
            android:id="@+id/editText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/editText1"
            android:ems="10" >
    
            <requestFocus />
        </EditText>
    
    </RelativeLayout>
    

    this is the class file in which drawable options are performed

    MainActivity.java
    
    package com.example.doubtedittext;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.ImageView;
    
    public class MainActivity extends Activity {
        private EditText etext;
        private ImageView imageView1;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            etext = (EditText) findViewById(R.id.editText1);
            imageView1 = (ImageView) findViewById(R.id.imageView1);
            etext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
    
                    if (hasFocus) {
                        imageView1.setVisibility(View.VISIBLE);
    
                    } else {
    
                        imageView1.setVisibility(View.INVISIBLE);
                    }
                }
            });
    
            imageView1.setOnClickListener(new View.OnClickListener() {
    
                @Override
                public void onClick(View v) {
    
                    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                            MainActivity.this);
    
                    // set title
                    alertDialogBuilder.setTitle("Your Title");
    
                    // set dialog message
                    alertDialogBuilder
                            .setMessage("Click yes to exit!")
                            .setCancelable(false)
                            .setPositiveButton("Yes",
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog,
                                                int id) {
                                            // if this button is clicked, close
                                            // current activity
                                            MainActivity.this.finish();
                                        }
                                    })
                            .setNegativeButton("No",
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog,
                                                int id) {
                                            // if this button is clicked, just close
                                            // the dialog box and do nothing
                                            dialog.cancel();
                                        }
                                    });
    
                    // create alert dialog
                    AlertDialog alertDialog = alertDialogBuilder.create();
    
                    // show it
                    alertDialog.show();
    
                }
            });
    
        }
    
    }
    

    the operation you required successfully performed above…..

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

Sidebar

Related Questions

My XMl Layout is as like below: <RelativeLayout android:id=@+id/dateSelectionLayout android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertical android:visibility=visible> <EditText
My activity's layout is as shown below. <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical> <FrameLayout android:id=@+id/title_bar
I have a View like this: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical > <ScrollView android:layout_width=fill_parent
The main.xml file code: <TableRow android:id=@+id/TableRow01 android:layout_width=wrap_content android:layout_height=wrap_content> <TextView android:text=User android:id=@+id/TextView01 android:layout_width=wrap_content android:layout_height=wrap_content></TextView> <EditText
Here is my xml <TextView android:id=@+id/itemNameTextView android:layout_width=wrap_content android:layout_height=wrap_content android:textColor=#000000 android:textSize=30sp android:layout_centerVertical=true android:drawableLeft=@drawable/doller android:drawablePadding=30dp android:layout_marginLeft=30dp/>
<?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/linearLayout1 android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical > <LinearLayout android:id=@+id/linearLayout2 android:layout_width=fill_parent android:layout_height=wrap_content
I am wondering why this happens : <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=horizontal android:layout_width=fill_parent android:gravity=center_vertical android:layout_height=wrap_content android:layout_gravity=top
I have a layout as below <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent
I have given my layout xml below. <?xml version=1.0 encoding=utf-8?> <TableLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent
I have a stored proc with the basic layout below that returns a sys_refcursor

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.