Edit various seek bars' progress from the progress of all of them exceeding a certain value
I am in the process of testing a few things before I go ahead and create my application. One of the things I am testing with is seek bars. In my app I am going to have around 5 of these and I want to get the bars to change their progress if the value of all the seekbars' progress is > 100. The issue I am having is that the progress is being tracked inside of the SeekBarListener function.
I find to find out if it is possible to achieve what I am looking for before I go and work on my app.
Thanks for your help in advance.
(See code below)
My XML:`<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="@+id/rel">
<TextView
android:id="@+id/progress1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress:"/>
<SeekBar
android:id="@+id/seek1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50"
android:layout_below="@+id/progress1"/>
<TextView
android:id="@+id/progress2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress"
android:layout_below="@id/seek1"
android:paddingTop="10dp"
/>
<SeekBar
android:id="@+id/seek2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/progress2"
android:max="100"
android:progress="20"
/>
</android.widget.RelativeLayout>
My Java:
package com.example.dfoden.budgetapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.SeekBar;
import android.widget.*;
public class MainActivity extends AppCompatActivity {
TextView proglab2;
TextView proglab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SeekBar seekBar = (SeekBar) findViewById(R.id.seek1);
seekBar.setOnSeekBarChangeListener(seekBarChangeListener);
SeekBar seek = (SeekBar) findViewById(R.id.seek2);
seek.setOnSeekBarChangeListener(seekBarChangeListener1);
int progress = seekBar.getProgress();
proglab = findViewById(R.id.progress1);
proglab.setText("Progress: " + progress);
int progress2 = seek.getProgress();
proglab2 = findViewById(R.id.progress2);
proglab2.setText("Progress: "+ progress2);
}
SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
proglab.setText("Progress: "+ progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
};
SeekBar.OnSeekBarChangeListener seekBarChangeListener1 = new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seek, int progress2, boolean fromUser) {
proglab2.setText("Progress: " + progress2);
}
public void onStartTrackingTouch(SeekBar seek) {
}
public void onStopTrackingTouch(SeekBar seek) {
}
};
}
java android
add a comment |
I am in the process of testing a few things before I go ahead and create my application. One of the things I am testing with is seek bars. In my app I am going to have around 5 of these and I want to get the bars to change their progress if the value of all the seekbars' progress is > 100. The issue I am having is that the progress is being tracked inside of the SeekBarListener function.
I find to find out if it is possible to achieve what I am looking for before I go and work on my app.
Thanks for your help in advance.
(See code below)
My XML:`<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="@+id/rel">
<TextView
android:id="@+id/progress1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress:"/>
<SeekBar
android:id="@+id/seek1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50"
android:layout_below="@+id/progress1"/>
<TextView
android:id="@+id/progress2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress"
android:layout_below="@id/seek1"
android:paddingTop="10dp"
/>
<SeekBar
android:id="@+id/seek2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/progress2"
android:max="100"
android:progress="20"
/>
</android.widget.RelativeLayout>
My Java:
package com.example.dfoden.budgetapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.SeekBar;
import android.widget.*;
public class MainActivity extends AppCompatActivity {
TextView proglab2;
TextView proglab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SeekBar seekBar = (SeekBar) findViewById(R.id.seek1);
seekBar.setOnSeekBarChangeListener(seekBarChangeListener);
SeekBar seek = (SeekBar) findViewById(R.id.seek2);
seek.setOnSeekBarChangeListener(seekBarChangeListener1);
int progress = seekBar.getProgress();
proglab = findViewById(R.id.progress1);
proglab.setText("Progress: " + progress);
int progress2 = seek.getProgress();
proglab2 = findViewById(R.id.progress2);
proglab2.setText("Progress: "+ progress2);
}
SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
proglab.setText("Progress: "+ progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
};
SeekBar.OnSeekBarChangeListener seekBarChangeListener1 = new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seek, int progress2, boolean fromUser) {
proglab2.setText("Progress: " + progress2);
}
public void onStartTrackingTouch(SeekBar seek) {
}
public void onStopTrackingTouch(SeekBar seek) {
}
};
}
java android
add a comment |
I am in the process of testing a few things before I go ahead and create my application. One of the things I am testing with is seek bars. In my app I am going to have around 5 of these and I want to get the bars to change their progress if the value of all the seekbars' progress is > 100. The issue I am having is that the progress is being tracked inside of the SeekBarListener function.
I find to find out if it is possible to achieve what I am looking for before I go and work on my app.
Thanks for your help in advance.
(See code below)
My XML:`<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="@+id/rel">
<TextView
android:id="@+id/progress1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress:"/>
<SeekBar
android:id="@+id/seek1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50"
android:layout_below="@+id/progress1"/>
<TextView
android:id="@+id/progress2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress"
android:layout_below="@id/seek1"
android:paddingTop="10dp"
/>
<SeekBar
android:id="@+id/seek2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/progress2"
android:max="100"
android:progress="20"
/>
</android.widget.RelativeLayout>
My Java:
package com.example.dfoden.budgetapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.SeekBar;
import android.widget.*;
public class MainActivity extends AppCompatActivity {
TextView proglab2;
TextView proglab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SeekBar seekBar = (SeekBar) findViewById(R.id.seek1);
seekBar.setOnSeekBarChangeListener(seekBarChangeListener);
SeekBar seek = (SeekBar) findViewById(R.id.seek2);
seek.setOnSeekBarChangeListener(seekBarChangeListener1);
int progress = seekBar.getProgress();
proglab = findViewById(R.id.progress1);
proglab.setText("Progress: " + progress);
int progress2 = seek.getProgress();
proglab2 = findViewById(R.id.progress2);
proglab2.setText("Progress: "+ progress2);
}
SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
proglab.setText("Progress: "+ progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
};
SeekBar.OnSeekBarChangeListener seekBarChangeListener1 = new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seek, int progress2, boolean fromUser) {
proglab2.setText("Progress: " + progress2);
}
public void onStartTrackingTouch(SeekBar seek) {
}
public void onStopTrackingTouch(SeekBar seek) {
}
};
}
java android
I am in the process of testing a few things before I go ahead and create my application. One of the things I am testing with is seek bars. In my app I am going to have around 5 of these and I want to get the bars to change their progress if the value of all the seekbars' progress is > 100. The issue I am having is that the progress is being tracked inside of the SeekBarListener function.
I find to find out if it is possible to achieve what I am looking for before I go and work on my app.
Thanks for your help in advance.
(See code below)
My XML:`<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="@+id/rel">
<TextView
android:id="@+id/progress1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress:"/>
<SeekBar
android:id="@+id/seek1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50"
android:layout_below="@+id/progress1"/>
<TextView
android:id="@+id/progress2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress"
android:layout_below="@id/seek1"
android:paddingTop="10dp"
/>
<SeekBar
android:id="@+id/seek2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/progress2"
android:max="100"
android:progress="20"
/>
</android.widget.RelativeLayout>
My Java:
package com.example.dfoden.budgetapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.SeekBar;
import android.widget.*;
public class MainActivity extends AppCompatActivity {
TextView proglab2;
TextView proglab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SeekBar seekBar = (SeekBar) findViewById(R.id.seek1);
seekBar.setOnSeekBarChangeListener(seekBarChangeListener);
SeekBar seek = (SeekBar) findViewById(R.id.seek2);
seek.setOnSeekBarChangeListener(seekBarChangeListener1);
int progress = seekBar.getProgress();
proglab = findViewById(R.id.progress1);
proglab.setText("Progress: " + progress);
int progress2 = seek.getProgress();
proglab2 = findViewById(R.id.progress2);
proglab2.setText("Progress: "+ progress2);
}
SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
proglab.setText("Progress: "+ progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
};
SeekBar.OnSeekBarChangeListener seekBarChangeListener1 = new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seek, int progress2, boolean fromUser) {
proglab2.setText("Progress: " + progress2);
}
public void onStartTrackingTouch(SeekBar seek) {
}
public void onStopTrackingTouch(SeekBar seek) {
}
};
}
java android
java android
edited Nov 22 '18 at 22:52
Andrew Thompson
153k27163340
153k27163340
asked Nov 22 '18 at 12:21
DFodenDFoden
11
11
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53430917%2fedit-various-seek-bars-progress-from-the-progress-of-all-of-them-exceeding-a-ce%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53430917%2fedit-various-seek-bars-progress-from-the-progress-of-all-of-them-exceeding-a-ce%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown