Android: First widget taking value of second when screen orientation is changed

I coded a custom component namely CountWidget. It have two buttons plus and minus, which are used to increase/decrease value of counter. A text view shows the value of counter.

My Activity have two counters.

<?xml version="1.0" encoding="utf-8"?>    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    xmlns:custom="http://schemas.android.com/apk/res-auto"    android:orientation="vertical"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.restroshop.countwidget.MainActivity">     <com.restroshop.components.CountWidget       android:id="@+id/counter1"       android:layout_width="wrap_content"       android:layout_height="wrap_content"       custom:max="15"       custom:min="5"       android:paddingBottom="10dp" />      <com.restroshop.components.CountWidget       android:id="@+id/counter2"       android:layout_width="wrap_content"       android:layout_height="wrap_content"       custom:max="15"       custom:min="5"       android:paddingBottom="10dp" />     <Button       android:id="@+id/btn"       android:layout_width="wrap_content"       android:layout_height="wrap_content" />  </LinearLayout> 

So let's say counter1 have a value 7 and counter2 have value 8. They both get the value 8 if screen is rotated.

Because code is a bit large to paste here so I am providing link to my github repo.

https://github.com/kuldeepiitg/Android/tree/master/CountWidget

Replay

Category: android Time: 2016-07-30 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.136 (s). 12 q(s)