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
This week's giveaway is in the
Testing
forum.
We're giving away four copies of
TDD for a Shopping Website LiveProject
and have Steven Solomon on-line!
See
this thread
for details.
Win a copy of
TDD for a Shopping Website LiveProject
this week in the
Testing
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
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
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: 4739
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.
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
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...