Update Textview inside for and while loop
up vote
-2
down vote
favorite
i have a structure of code that looks like this
for () {
while(){
}
while(){
}
while(){
}
while(){
}
}
focus on those while
my target is to update a textview
when those while is moving. what should i do?
What i mean is this here is my entire code
File file = new File(FilePathname_CUS);
CsvReader csvReader = new CsvReader();
try (CsvParser csvParser = csvReader.parse(file, StandardCharsets.UTF_8)) {
if (count_row(FilePathname_SAMPLE) != 0) {
myDb.delete_customer(current_email);
Thread thread;
final Handler handler = new Handler();
thread = new Thread(new Runnable() {
public void run() {
int index = 0;
CsvRow row;
while ((row = csvParser.nextRow()) != null) {
myDb.insert_customer(
row.getField(0),
row.getField(1),
row.getField(2),
row.getField(3),
row.getField(4),
row.getField(5),
row.getField(6),
row.getField(7),
row.getField(8),
row.getField(9)
);
index++;
float p = (float)index / (float)row_count;
p = p * (float)100;
handler.post(new Runnable() {
public void run() {
counter_load.setText((int)p);
}
});
try {
// Sleep for 100 milliseconds.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
thread.start();
}
}
my target is to update the textview inside the while loop
Please see my updated code
File file = new File(FilePathname_CUS);
CsvReader csvReader = new CsvReader();
Thread thread;
final Handler handler = new Handler();
try (CsvParser csvParser = csvReader.parse(file, StandardCharsets.UTF_8)) {
CsvRow row;
if (count_row(FilePathname_CUS) != 0) {
myDb.delete_customer(current_email);
while ((row = csvParser.nextRow()) != null) {
myDb.insert_customer(
row.getField(0),
row.getField(1),
row.getField(2),
row.getField(3),
row.getField(4),
row.getField(5),
row.getField(6),
row.getField(7),
row.getField(8),
row.getField(9),
row.getField(10)
);
Log.e("Inserting", "" + row.getField(0));
index++;
p = (float) index / (float) row_count;
p = p * (float) 100;
handler.post(new Runnable() {
public void run() {
counter.setText((String.valueOf(p)));
}
});
try {
// Sleep for 100 milliseconds.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} else {
}
}
android
|
show 11 more comments
up vote
-2
down vote
favorite
i have a structure of code that looks like this
for () {
while(){
}
while(){
}
while(){
}
while(){
}
}
focus on those while
my target is to update a textview
when those while is moving. what should i do?
What i mean is this here is my entire code
File file = new File(FilePathname_CUS);
CsvReader csvReader = new CsvReader();
try (CsvParser csvParser = csvReader.parse(file, StandardCharsets.UTF_8)) {
if (count_row(FilePathname_SAMPLE) != 0) {
myDb.delete_customer(current_email);
Thread thread;
final Handler handler = new Handler();
thread = new Thread(new Runnable() {
public void run() {
int index = 0;
CsvRow row;
while ((row = csvParser.nextRow()) != null) {
myDb.insert_customer(
row.getField(0),
row.getField(1),
row.getField(2),
row.getField(3),
row.getField(4),
row.getField(5),
row.getField(6),
row.getField(7),
row.getField(8),
row.getField(9)
);
index++;
float p = (float)index / (float)row_count;
p = p * (float)100;
handler.post(new Runnable() {
public void run() {
counter_load.setText((int)p);
}
});
try {
// Sleep for 100 milliseconds.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
thread.start();
}
}
my target is to update the textview inside the while loop
Please see my updated code
File file = new File(FilePathname_CUS);
CsvReader csvReader = new CsvReader();
Thread thread;
final Handler handler = new Handler();
try (CsvParser csvParser = csvReader.parse(file, StandardCharsets.UTF_8)) {
CsvRow row;
if (count_row(FilePathname_CUS) != 0) {
myDb.delete_customer(current_email);
while ((row = csvParser.nextRow()) != null) {
myDb.insert_customer(
row.getField(0),
row.getField(1),
row.getField(2),
row.getField(3),
row.getField(4),
row.getField(5),
row.getField(6),
row.getField(7),
row.getField(8),
row.getField(9),
row.getField(10)
);
Log.e("Inserting", "" + row.getField(0));
index++;
p = (float) index / (float) row_count;
p = p * (float) 100;
handler.post(new Runnable() {
public void run() {
counter.setText((String.valueOf(p)));
}
});
try {
// Sleep for 100 milliseconds.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} else {
}
}
android
post you code first.
– Ali Ahmed
Nov 8 at 11:37
What do you mean by while is moving?
– gratien asimbahwe
Nov 8 at 11:37
please see my updated post
– myown email
Nov 8 at 11:42
so whatsa your issue?
– Alesandro Giordano
Nov 8 at 11:46
my textview doest update any text while inside the loop
– myown email
Nov 8 at 11:47
|
show 11 more comments
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
i have a structure of code that looks like this
for () {
while(){
}
while(){
}
while(){
}
while(){
}
}
focus on those while
my target is to update a textview
when those while is moving. what should i do?
What i mean is this here is my entire code
File file = new File(FilePathname_CUS);
CsvReader csvReader = new CsvReader();
try (CsvParser csvParser = csvReader.parse(file, StandardCharsets.UTF_8)) {
if (count_row(FilePathname_SAMPLE) != 0) {
myDb.delete_customer(current_email);
Thread thread;
final Handler handler = new Handler();
thread = new Thread(new Runnable() {
public void run() {
int index = 0;
CsvRow row;
while ((row = csvParser.nextRow()) != null) {
myDb.insert_customer(
row.getField(0),
row.getField(1),
row.getField(2),
row.getField(3),
row.getField(4),
row.getField(5),
row.getField(6),
row.getField(7),
row.getField(8),
row.getField(9)
);
index++;
float p = (float)index / (float)row_count;
p = p * (float)100;
handler.post(new Runnable() {
public void run() {
counter_load.setText((int)p);
}
});
try {
// Sleep for 100 milliseconds.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
thread.start();
}
}
my target is to update the textview inside the while loop
Please see my updated code
File file = new File(FilePathname_CUS);
CsvReader csvReader = new CsvReader();
Thread thread;
final Handler handler = new Handler();
try (CsvParser csvParser = csvReader.parse(file, StandardCharsets.UTF_8)) {
CsvRow row;
if (count_row(FilePathname_CUS) != 0) {
myDb.delete_customer(current_email);
while ((row = csvParser.nextRow()) != null) {
myDb.insert_customer(
row.getField(0),
row.getField(1),
row.getField(2),
row.getField(3),
row.getField(4),
row.getField(5),
row.getField(6),
row.getField(7),
row.getField(8),
row.getField(9),
row.getField(10)
);
Log.e("Inserting", "" + row.getField(0));
index++;
p = (float) index / (float) row_count;
p = p * (float) 100;
handler.post(new Runnable() {
public void run() {
counter.setText((String.valueOf(p)));
}
});
try {
// Sleep for 100 milliseconds.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} else {
}
}
android
i have a structure of code that looks like this
for () {
while(){
}
while(){
}
while(){
}
while(){
}
}
focus on those while
my target is to update a textview
when those while is moving. what should i do?
What i mean is this here is my entire code
File file = new File(FilePathname_CUS);
CsvReader csvReader = new CsvReader();
try (CsvParser csvParser = csvReader.parse(file, StandardCharsets.UTF_8)) {
if (count_row(FilePathname_SAMPLE) != 0) {
myDb.delete_customer(current_email);
Thread thread;
final Handler handler = new Handler();
thread = new Thread(new Runnable() {
public void run() {
int index = 0;
CsvRow row;
while ((row = csvParser.nextRow()) != null) {
myDb.insert_customer(
row.getField(0),
row.getField(1),
row.getField(2),
row.getField(3),
row.getField(4),
row.getField(5),
row.getField(6),
row.getField(7),
row.getField(8),
row.getField(9)
);
index++;
float p = (float)index / (float)row_count;
p = p * (float)100;
handler.post(new Runnable() {
public void run() {
counter_load.setText((int)p);
}
});
try {
// Sleep for 100 milliseconds.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
thread.start();
}
}
my target is to update the textview inside the while loop
Please see my updated code
File file = new File(FilePathname_CUS);
CsvReader csvReader = new CsvReader();
Thread thread;
final Handler handler = new Handler();
try (CsvParser csvParser = csvReader.parse(file, StandardCharsets.UTF_8)) {
CsvRow row;
if (count_row(FilePathname_CUS) != 0) {
myDb.delete_customer(current_email);
while ((row = csvParser.nextRow()) != null) {
myDb.insert_customer(
row.getField(0),
row.getField(1),
row.getField(2),
row.getField(3),
row.getField(4),
row.getField(5),
row.getField(6),
row.getField(7),
row.getField(8),
row.getField(9),
row.getField(10)
);
Log.e("Inserting", "" + row.getField(0));
index++;
p = (float) index / (float) row_count;
p = p * (float) 100;
handler.post(new Runnable() {
public void run() {
counter.setText((String.valueOf(p)));
}
});
try {
// Sleep for 100 milliseconds.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} else {
}
}
android
android
edited Nov 8 at 12:04
asked Nov 8 at 11:28
myown email
347
347
post you code first.
– Ali Ahmed
Nov 8 at 11:37
What do you mean by while is moving?
– gratien asimbahwe
Nov 8 at 11:37
please see my updated post
– myown email
Nov 8 at 11:42
so whatsa your issue?
– Alesandro Giordano
Nov 8 at 11:46
my textview doest update any text while inside the loop
– myown email
Nov 8 at 11:47
|
show 11 more comments
post you code first.
– Ali Ahmed
Nov 8 at 11:37
What do you mean by while is moving?
– gratien asimbahwe
Nov 8 at 11:37
please see my updated post
– myown email
Nov 8 at 11:42
so whatsa your issue?
– Alesandro Giordano
Nov 8 at 11:46
my textview doest update any text while inside the loop
– myown email
Nov 8 at 11:47
post you code first.
– Ali Ahmed
Nov 8 at 11:37
post you code first.
– Ali Ahmed
Nov 8 at 11:37
What do you mean by while is moving?
– gratien asimbahwe
Nov 8 at 11:37
What do you mean by while is moving?
– gratien asimbahwe
Nov 8 at 11:37
please see my updated post
– myown email
Nov 8 at 11:42
please see my updated post
– myown email
Nov 8 at 11:42
so whatsa your issue?
– Alesandro Giordano
Nov 8 at 11:46
so whatsa your issue?
– Alesandro Giordano
Nov 8 at 11:46
my textview doest update any text while inside the loop
– myown email
Nov 8 at 11:47
my textview doest update any text while inside the loop
– myown email
Nov 8 at 11:47
|
show 11 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53206837%2fupdate-textview-inside-for-and-while-loop%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
post you code first.
– Ali Ahmed
Nov 8 at 11:37
What do you mean by while is moving?
– gratien asimbahwe
Nov 8 at 11:37
please see my updated post
– myown email
Nov 8 at 11:42
so whatsa your issue?
– Alesandro Giordano
Nov 8 at 11:46
my textview doest update any text while inside the loop
– myown email
Nov 8 at 11:47