Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Java Persistence with Spring Data and Hibernate
this week in the
Spring
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Tim Cooke
Paul Clapham
Liutauras Vilda
Sheriffs:
Junilu Lacar
Rob Spoor
Jeanne Boyarsky
Saloon Keepers:
Stephan van Hulst
Carey Brown
Tim Holloway
Piet Souris
Bartenders:
Forum:
Android
Change colour programmatically?
Glenda Karen
Ranch Hand
Posts: 105
2
posted 1 year ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello,
I have a few round circles in my app. I would like to change their colour depending on the response I get from an http request.
The cirlces look like:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > <size android:width="80dp" android:height="80dp" /> <solid android:color="#00FF00"/> </shape>
and are being added in as
FrameLayout
like:
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:layout_width="50dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/temperature" android:textSize="20sp" /> <FrameLayout android:layout_width="32dp" android:layout_height="match_parent" android:background="@drawable/circle"></FrameLayout> </LinearLayout>
Then in the
java
code the http request is being made:
try { response = client.newCall(request).execute(); System.out.println(response.body().string()); } catch (IOException e) { e.printStackTrace(); } return String.valueOf(response); }
So if the response is 1, the circle will turn green, if the response is 2 the circle will turn blue etc.
Thanks so much!
Norm Radder
Rancher
Posts: 4936
38
posted 1 year ago
Number of slices to send:
Optional 'thank-you' note:
Send
Give it an id so the code can access it and call its methods.
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Set Relevant Maximum ListView Height
Help With My Android Calculator Project
how to clear an edittext by cross button in the right side
PDF Viewer and Android
ListView Problem
More...