2

i m creating a browser for my self.so when i set text of edittext by passing the url of some link it shows only the beginning of the url.Ex- if the url is

https://stackoverflow.com/howtocreateabutton/

but the edittext shows only

https://stackoverflow.com/how

beacuse of overflow from the screen but i want to display the last of the link like -

com/howtocreateabutton/

Xml Code for Edittext:

    <EditText
    android:layout_width="0dp"
    android:layout_height="40dp"
    android:layout_weight="10"
    android:onClick="enterAgain"
    android:layout_marginTop="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:inputType="textUri"
    android:gravity="center_vertical"
    android:hint="Enter URL..."
    android:autoText="true"
    android:layout_marginRight="10dp"
    android:textColorHighlight="#4384d4"
    android:textColor="#c1bfbf"
    android:maxLines="1"
    android:scrollHorizontally="true"
    android:foregroundGravity="right"
    android:clickable="true"
    android:imeOptions="actionGo"
    android:id="@+id/edit_url"
    android:background="#FFFFFF"/>

....help me guys...;(

Community
  • 1
  • 1
Ajay Chauhan
  • 1,471
  • 4
  • 17
  • 37

3 Answers3

2

you can do it as following:

et.setSelection(et.getText().length());

i tested and it worked for me if anything went wrong put let me know in the comments

Amir Ziarati
  • 14,248
  • 11
  • 47
  • 52
  • i am using et.setSelection(0,et.gettext().length()); to select whole url inside edittext..selection of this url is must .....but the problem is dat during selection edittext displaying url from start i.e from http;// but i want to display the end part of url.... – Ajay Chauhan Oct 10 '16 at 12:56
0

If you want to show only the end of text in edittext add this to your edittext xml

android:ellipsize="end"

Update see if this answer can help you

https://stackoverflow.com/a/4233683/3868511

Community
  • 1
  • 1
steveen zoleko
  • 395
  • 8
  • 23
  • Nope...same for u my pal...I want to set whole of my url in edit text.... Not just last part... – Ajay Chauhan Oct 10 '16 at 11:26
  • i think there is something wrong with your edit text cuz the default behaviour is the way you wish. put your edit text code in your question – Amir Ziarati – steveen zoleko Oct 10 '16 at 12:06
0

First get your editText data in String and split it into two parts so that you can display the last part of your code.

dielan
  • 86
  • 9
  • Not a solution for which I m looking for....I want to set whole url...so anybody can edit the who url...ur solution is not providing me this functionality – Ajay Chauhan Oct 10 '16 at 11:23