FAQ Database Discussion Community


How to display Strings from ArrayList in TextView

java,android,sharedpreferences,android-textview
I need to display current values in TextView (after removing String). I'm adding String when button is On and I need to remove it, when it's Off ( I don't know if I do it well), next I need to display Strings in TextView without deleted String. I need to...

Android setText always crash

android,android-textview
I'm using Android Studio to Create a Default Navigation Drawer Activity. And I just do "setText", my app always crashed. Here is my code. protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); mTitle = getTitle(); // Set up the drawer. mNavigationDrawerFragment.setUp( R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));...

Trying to create custom textview but showing error

android,android-textview
Here is my code for class test.java package com.example.testdroid; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.widget.TextView; public class test extends TextView{ public test(Context context) { super(context); // TODO Auto-generated constructor stub this.setText("Hello World"); this.setTextSize(20f); this.setTextColor(Color.RED); } protected void onDraw (Canvas canvas) { super.onDraw(canvas); } } main.xml <RelativeLayout...

Decapitalizing text in Android view

android,android-view,android-textview
I want to insert a text into an Android view, like a button. The problem is that I want the capitalize some specific characters in my text, but Android capitalize all the text I in the text field. For example, I labeled a button with the text "ExaMple" in which...

setText to a saved preference

java,android,sharedpreferences,android-textview
I have saved a highscore to shared preferences, i would like to display the high score on the main menu and have it stay there even if you close the app and reopen it. i have got it to work so that it changes the textview to the highscore when...

Android - How to create a view like this using recycler view?

android,android-textview,recyclerview,android-cardview,roundedbitmapdrawable
Can anyone help me with this custom layout inside a card view? I am showing a list of items and need to show an item like this. But cant understand how to implement this. Basically, There is a recycler view Inside it, there are cards. The card has a...

Issue with changing the colour of textview - android fragment

android,android-fragments,android-textview
I have 2 text views in my fragment. When opening of the fragment 1st text view will be in red(#e92624). When pressed 2nd text view then 1st view should be black(#D8000000) and 2nd text view should turn to red. in my onCreate I have, mQuickReturnViewPas.setBackgroundColor(Color.parseColor("#e92624")); if (selectedView != null) mQuickReturnViewPas.setBackgroundColor(Color...

how do i check if the edit text view contains 2 white spaces?

android,android-fragments,android-edittext,android-view,android-textview
Currently my edit text view checks if the searched term contains one space as follows: if(mSearchView.getText().toString().contains(" ") How do I make it such that it makes sure it checks if the searchview contains 2 spaces between 3 search terms for example: "here it is"...

Adding OnTouch and OnClickListener to the links in a TextView and changing background color of the link

android,android-textview,linkmovementmethod
I have a textview and links in it. I want the links highlighted when I touch them and also I want to open a Alertdialog when I longclick them. I tried to reach the solution by customizing URLSpan, but, since I can't access to mView before OnClick is called, I...

Android: for loop through EditText, CheckBoxed and Spinners to setErrors

android,for-loop,android-textview,android-spinner
This piece of code gets resources from a list and set errors for each field on a registration form, one of them is a spinner, so when the error is on the spinner, it fails due to the fact that the spinner is not a subclass of TextView. How can...

How do I create a dictionary-like android app using HashMap for words and their respective meanings?

android,dictionary,android-edittext,hashmap,android-textview
I'm trying to create an app that works like a dictionary (using HashMap), where a user types in a word (jargon) in the textEdit and if that word matches any of the words in HashMap, will display my predefined meaning of the word in a textView when user hits enter....

How to Change the Text Selection Toolbar color which comes when we copy a text?

android,android-textview,android-5.0-lollipop,android-theme
I am developing an application and i set "android:textIsSelectable" for the TextViews. But my material theme is not matching with the TextSelection appBar. Is there a way by which i can change the color of that appBar ?? Attached the Image Below Check it :- ...

Android TextView should scroll vertically automatically

java,android,xml,android-textview
I need a TextView which scrolls automatically vertically. This is my layout code: activity_info.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/iView" android:layout_width="100dp" android:layout_height="100dp" android:layout_centerHorizontal="true" android:contentDescription="@string/info" android:src="@mipmap/infoImage" /> <TextView android:id="@+id/tView"...

Get Response, Url and Url code in Textview

android,android-asynctask,textview,android-textview
I am trying to make a post request to a url and get the URL, Response Code and Response displayed in a TextView. I am able to get the URL and Response Code in the Logs but Unable to get the response. Please check the code and tell how to...

How to create only two edges rounded textView in android.?

android,xml,android-layout,android-textview
I need to create a textview with only TopLeft and TopRight coners with round shape and no others, I've written an XML for 4 corner round, but it not supporting for two corner round. Here is the XML <?xml version="1.0" encoding="utf-8"?> <!-- res/drawable/rounded_edittext.xml --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"> <solid android:color="#FFFFFF"/>...

How to get some specific lines in a textview that have a particular symbol

java,android,textview,android-textview
I have a textview which has a long text lines like below: $hello all my name is Ford I'm an electronic engineer and so blah blah blah and something else here so other texts.... $and this is another line like the first line and so other normal texts my question...

Align TextView above EditText

java,android,android-layout,android-edittext,android-textview
I want to align a TextView above an EditText. The following code is working well when the TextView is not higher than the space between the Top Margin of the window (red line) and the EditText (green line), like in the screenshot. The problem occurs when the TextView has more...

How to set the icon above string in SlidingTabLayout in android?

android,android-layout,android-viewpager,android-imageview,android-textview
I am using the SlidingTabLayout to create the tab layout , the problem is , it use spannableString, and the icon is at the left of the string, and what I would like to achieve is icon is at the top of the string Here is the tab xml: <?xml...

Animating a TextView height increasing

android,android-layout,android-animation,android-textview
Could someone please post a simple example of how to animate a TextView growing in height from 0dp to a dynamic value? I would like to increase the height of a textview, but allow the user to SEE it like an animation. The only condition is I know my max...

Android some TextView's id to array and fetch from that to assign text

android,android-textview
I am trying to save some TextView id's to array and fetch that with for loop to assign text. or example: String[] other_stuff_items = other_soft.split(";"); int[] tvs ={ R.id.tv_other_stuff_one, R.id.tv_other_stuff_two, R.id.tv_other_stuff_three }; int[] ivs ={ R.id.ix_other_stuff_one, R.id.ix_other_stuff_two, R.id.ix_other_stuff_three }; after saving TextView id's to array I'm trying to get array...

TextView and EditText cut off in LinearLayout

android,android-layout,android-edittext,android-view,android-textview
I have a LinearLayout with horizontal orientation in which I add some TextView and EditText dynamically. My problem is when the TextView is long, it is cut off (by height) and the EditText is invisible. Adding padding to the views didn't solve it. When setting the LinearLayout minHeight value, the...

TextColors in a TextView

android,android-textview
This may be a ridiculous question ever, but still I want to reduce my effort of creating a lot of text views. I have text view that contains Name:Value format [Suppose Name:Android] In this case all the attributes for the text view will be same except the color and also...

Set text color to secondary color programmatically

java,android,android-layout,android-textview
How can I set the color of my text to "textColorSecondary" programmatically? I've tried the code below but it doesn't work. Does anyone know what's wrong with the code? TextView tv1 = ((TextView)v.findViewById(R.id.hello_world)); tv1.setTextColor(Color.textColorSecondary); ...

Set textColorLink on textAllCaps?

android,url,android-textview
I have a textview that should be in all caps and mark any urls found in it with a specific color, so naturaly I've tried textColorLink, with the option textAllCaps="true", however the url is not colored, my guess is that the regex does not match uppercase urls, since the url...

how to get the text of a edit text when after pressing a key

android,android-listview,android-textview,keylistener,android-event
I want to search a ListView when user types a text in a EditText. after pressing a key I need to get the typed part of text to begin the search. so is there any method I can use?? simple help is highly appreciated.

Set different text size in Android TextView

android,android-textview
I have one TextView with only 1 line of text. Now I have to put an extra line to set the state of the user. So I set the property android:lines="2" the textview looks like: <TextView android:id="@+id/providerName" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1.0" android:ellipsize="marquee" android:fontFamily="sans-serif-light" android:lines="2" android:textAppearance="?android:attr/textAppearanceLarge" android:textStyle="bold" /> The way I add...

Android Wheel day and time picker get values

android,button,android-textview,wheel
Hi All I am using Wheel lib in app, I want to show date and time in Toast when I click button. How can I do it?? This is code of the example where I just show date and time in wheel but I want to get and show date...

Android-value not able to set in textview

android,android-textview
I have a SQLite database add2cart which stores details of products added to cart.I need to display the number of products each user have in their cart,in a text view. crtno is my textview.I want to display the number in textview when each user clicks add2cart button. code protected void...

TextView doesn't show the required text

java,android,android-textview,android-viewgroup
My MainActivity class has an if that checks is something is true it starts a new Activity which sets the text of a TextView to what I want. MainActivity: public static int caseA = 1; if(caseA) { Intent i = new Intent(Timer.this, WorkTimerNotification.class); startActivity(i); } then it goes to the...

SimpleCursorAdapter - set 2 columns to 1 view

android,android-textview,simplecursoradapter
I have a SQLite Datebase from which I am displaying data in ListView by SimpleCursorAdapter. I have 2 columns but I want to displey them in 1 TextView. How can I do that? Thanks

how to start contextual action bar for text view programatically with default opions copy and select all?

android,android-actionbar,android-edittext,android-textview,contextual-action-bar
Is there any way to programatically start contextual action bar associated with a text view, on a button click? It should contain default options of copy/select all as well. Basically, I want to show the selection handles in my text view and the android default copy/select all option in action...

setText of TextView on Async Task complete

android,android-asynctask,android-textview
I want to return a specific string using ksoap2 web service in my android app. Web service is returning the correct value but the set text is not getting updated once the task is complete. I need to do something (like trying to open the navigation drawer) then its getting...

get Text on TextView's background [closed]

android,android-activity,android-textview
can any one tell me how to get background image over TextView's text like this i m able to get background image over TextView but image is showing below on textView like this can anyone help me thanks in Advance ...

add Layout programmatically inside another one

android,android-layout,android-imageview,android-textview
I have an xml file (option_element.xml) that contains a ImageView and a TextView <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="-18dp" > <ImageView android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/option_button" /> <TextView...

How to update TextView with EditText realtime using java Android Studio

android-studio,android-edittext,android-textview
Hey guys and gals I am having trouble figuring out the process and method to best solve my problem.I have an app in which user created text is shown in a secretive font/language, while English(non-secretive) text is displayed in the textview. JAVA import android.graphics.Typeface; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu;...

TextView background black only on Galaxy devices

android,android-layout,android-textview,android-xml
On Galaxy S2 & S3's, my textview's background color is black while on every other device it's transparent, which is what I want. How can I fix it so the textview is transparent on all devices? <?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="fill_parent" > <TextView android:id="@+id/desc" android:layout_width="fill_parent" android:layout_height="40dip" android:layout_alignParentRight="true"...

How can I remove setBackgroundResource when new View is clicked?

java,android,android-textview
I have a Horizontal Listview with a textview. When I click on a textview in the view, that particular textview gets a border. public View getView(int position, View convertView, ViewGroup parent) { View retval = LayoutInflater.from(parent.getContext()).inflate(R.layout.minute_listview, null); Typeface afBold = Typeface.createFromAsset(getAssets(), "fonts/AftenScreen-Bold.ttf"); minuteText = (TextView) retval.findViewById(R.id.title); Button button = (Button)...

How to get default text size from TextView on widget?

android,android-widget,android-textview
I have a home screen widget with TextView: <TextView android:id="@+id/textView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ellipsize="none" android:singleLine="true" android:textStyle="bold" /> I need to get the size of this text. I am trying to get default TextView's size text like this: TextView defaultTextView = new TextView(context); float sourceTextSize = defaultTextView.getTextSize(); And sourceTextSize contains 21. But...

Checking which textview is clicked android

android,android-textview
I want to put two textviews and then decide which one of them is clicked to start the appropriate activity? I don't want to use buttons. Any idea??

update textview title in an Activity from a service

android,service,android-textview
i have an homeActivity which contains a webview with an actionbar, the title of the actionbar is an textview public static TextView mTitleTextView; and also has an class which do receive gcm message public class GCMNotificationIntentService extends IntentService { after the app received a message i want to put the...

Trouble with Android character by character display text animation

android,android-animation,android-textview
I'm following this solution Android character by character display text animation I get unresolved method for setContentView Here is the Typewriter Class public class Typewriter extends TextView { private CharSequence mText; private int mIndex; private long mDelay = 500; //Default 500ms delay public Typewriter(Context context) { super(context); } public Typewriter(Context...

Null Object Preferences Edittext on Android [closed]

android,textview,android-textview,null-object
I am new Android programming. I am at bottleneck. I am trying to chatapp. when I click the item these errors occur : java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.EditText.setInputType(int)' on a null object reference at com.senturk.fatih.chat03.Chat.onCreate(Chat.java:55) and here is line 55 txt.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_MULTI_LINE); and I guess I should add...

Android Text Size large when it scroll

android,scroll,scrollview,android-textview
I am working on an app, I am stuck on 1 point. I have 3 items in array an I want to show them in scrollview. But my problem is that whenever any text position comes in center its textsize will large. If position 0 comes in center its text...

How to prevent deleting the first character of edit text in Android

android,android-edittext,substring,android-textview
This is one of my Edit text in the application <EditText android:id="@+id/etFolder" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="/pictures" android:ems="10" > When it appear at first time it comes with "/pictures" User can change the text and enter another word. but how to prevent deleting "/" of Edit text. user can delete all other...

XAMARIN (C#) - Is There A Way To Underline A TextView Programmatically?

c#,android,xamarin,textview,android-textview
I know there are some other ways to do it (I think in Java you do something like this .SetPaintFlags(Paint.Underline_Text_Flag);) -and I do understand that it could me sort of emulated using Draw Line and there is a way to do it predefining it in xml file. The question is...

Multiple views in Android [duplicate]

java,android,background-image,android-textview,setcontentview
This question already has an answer here: Adding child views to Relative Layout 2 answers I have a background image: android:background="@drawable/bg"> and a TextView: final TextView theTimer = new TextView(this); If I use setContentView I can only place one of them on the screen. How can I fit them...

drawableEnd textview property not working in mobile android

android,xml,android-textview,android-drawable,xml-drawable
Hello friends I want to my drawable image to end of my textview so i set my layout as below xml file <TextView android:id="@+id/text_four" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/text_two" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:text="Go ahead and get to the area you want then" android:drawableEnd="@drawable/alogo_small" android:textColor="@android:color/black" android:textSize="@dimen/text_15" android:visibility="visible" /> when i run above...

How use Android supplied (custom) fonts?

android,fonts,android-textview,android-assets,android-sdk-2.3
According to the Android Typography page Roboto font was introduced in Ice Cream Sandwich. I can download the .ttf files there or I can find it (and many others) in the <android-sdk>/platforms/android-x/data/fonts directory (where x is ICS version and higher). If I want to actually use this font in my...

TextView Ellipsizing not working

android,android-textview
I had achieved the auto scrolling of text inside a text view. I wanted to do the same again but its not working. I have also set the setSelected(true) XML code: <TextView android:id="@+id/tvScroll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/ivlogo" android:layout_toStartOf="@+id/ivlogo" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:singleLine="true" android:text="left...

Align TextViews to top of LinearLayout

android,android-layout,alignment,android-linearlayout,android-textview
I'm creating an app that has four different TextView inside a LinearLayout. The LinearLayout has a weight sum of 4 and every TextView has a weight of 1 (to make them with evenly width). My first problem is that two of the TextViews has a bigger height than the other...

Dynamically create textview in center

android,android-layout,android-textview,android-relativelayout
I have a list of items and a relative layout. I want to add as many relative layouts as the no of items in list and textview in each on them. My problem is, I am not able to position the textview in the centre of the layout. Below in...

spannablestring is not working for programatically createed button

android,android-textview,spannablestring
I know SpannableString is possible to set different text size in one textview but if textview is added programatically its not working. String s = "Best Ever"; SpannableString ss1 = new SpannableString(s); ss1.setSpan(new RelativeSizeSpan(2f), 0, 4, 0); // set size ss1.setSpan(new ForegroundColorSpan(Color.RED), 0, 4, 0); // set color TextView tv...

Android align textview to textview

android,android-textview
there is code below. I need align textview to textview. The firsts one with id:test1 is very long with many lines and the second textview should be align to the first one test1 to the end of it. Any help? <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="@dimen/standard_margin" android:orientation="vertical"> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView...

Textview multiple underline text getting onClick dynamically in android

android,html,textview,android-textview
I should html content load on textview its ok and display well but how to handle multiple underline word getting onclick dynamically. How can i getting click like as Phnom Penh, Siem Reap & so on etc..???? Thanks in advance See snapshot ...

marquee text of textview in actionbar not marquee anyone after setText

android,android-layout,android-textview
I have a ActionBar with a TextView <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="50dp" > <TextView android:id="@+id/title_text" android:text="This will run the marquee animation forever" android:textSize="@dimen/abc_text_size_title_material_toolbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee"...

settext for more than one edittext in vertical lines [closed]

java,android,android-edittext,android-textview,settext
I'm beginner in android development and i'm trying to build an app with multiple equations and i need the result to be viewed in one text and in vertical lines every result for equation viewed in line, i know how to show them together but it will show them either...

How to show textview is clickable?

android,textview,android-textview
I have five text view and all are clickable, how to give them a visual effect so that the user can identify it is clickable. I already dropped the idea of underlining the textview, so is there any other way available. My code <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"...