powered by simpleCommunicator - 2.0.51     © 2025 Programmizd 02
Форумы / Android [игнор отключен] [закрыт для гостей] / Android программирование
2 сообщений из 2, страница 1 из 1
Android программирование
    #38338296
Aina2008
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здорова товарищи

у меня на форме есть несколько TextView, EditText и есть еще SeekBar

Код

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
package com.example.tipcalculator;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

public class MainActivity extends Activity {

	private static final String BILL_TOTAL = "BILL_TOTAL";
	private static final String CUSTOM_PERCENT = "CUSTOM_PERCENT";
	
	private double currentBillTotal;
	private int currentCustomPercent;
	
	private EditText tip10EditText;
	private EditText total10EditText;	
	private EditText tip15EditText;
	private EditText total15EditText;
	private EditText tip20EditText;
	private EditText total20EditText;
	
	private EditText billEditText;
	
	private TextView customTipTextView;
	
	private EditText tipCustomEditText;
	private EditText totalCustomEditText;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		if (savedInstanceState == null) {
			
			currentBillTotal = 0.0;
			currentCustomPercent = 18;
			
		} else {
			
			currentBillTotal = savedInstanceState.getDouble(BILL_TOTAL);
			currentCustomPercent = savedInstanceState.getInt(CUSTOM_PERCENT);
			
			tip10EditText = (EditText) findViewById(R.id.tip10EditText);
			total10EditText = (EditText) findViewById(R.id.total10EditText);
			tip15EditText = (EditText) findViewById(R.id.tip15EditText);
			total15EditText = (EditText) findViewById(R.id.total15EditText);
			tip20EditText = (EditText) findViewById(R.id.tip20EditText);
			total20EditText = (EditText) findViewById(R.id.total20EditText);
			
			customTipTextView = (TextView) findViewById(R.id.customTipTextView);
			
			tipCustomEditText = (EditText) findViewById(R.id.tipCustomEditText);
			totalCustomEditText = (EditText) findViewById(R.id.totalCustomEditText);
			
			billEditText = (EditText) findViewById(R.id.billEditText);
			
		//	billEditText.addTextChangedListener(billEditTextWatcher);
			final SeekBar customSeekBar = (SeekBar) findViewById(R.id.customSeekBar);
			customSeekBar.setOnSeekBarChangeListener(customSeekBarListener);			
		}
	}

	
	private TextWatcher billEditTextWatcher = new TextWatcher() {
		
		@Override
		public void onTextChanged(CharSequence s, int start, int before, int count) {
		
		}
		
		@Override
		public void beforeTextChanged(CharSequence s, int start, int count,
				int after) {
		
		}
		
		@Override
		public void afterTextChanged(Editable s) {
			
		}
	};
	
	
	private SeekBar.OnSeekBarChangeListener customSeekBarListener = new SeekBar.OnSeekBarChangeListener() {
		
		@Override
		public void onStopTrackingTouch(SeekBar seekBar) {	
			
		}
		
		@Override
		public void onStartTrackingTouch(SeekBar seekBar) {			
			
		}
		
		@Override
		public void onProgressChanged(SeekBar seekBar, int progress,
				boolean fromUser) {
		    //currentCustomPercent = seekBar.getProgress();
		    customTipTextView.setText(String.valueOf(seekBar.getProgress()));
		    //updateCustom();
		}
	};	
	
	
	private void updateStandart() {
		

		double tenPercentTip = currentBillTotal * .1;
		double tenPercentTotal = currentBillTotal + tenPercentTip;
		
		tip10EditText.setText(String.format(" %0.2f", tenPercentTip));
		total10EditText.setText(String.format(" %0.2f", tenPercentTotal));
		
		double fifteenPercentTip = currentBillTotal * .15;
		double fifteenPercentTotal = currentBillTotal + fifteenPercentTip;
		
		tip15EditText.setText(String.format(" %0.2f", fifteenPercentTip));
		total15EditText.setText(String.format(" %0.2f", fifteenPercentTotal));		
		
		double twentyPercentTip = currentBillTotal * .20;
		double twentyPercentTotal = currentBillTotal + twentyPercentTip;
		
		tip20EditText.setText(String.format(" %0.2f", twentyPercentTip));
		total20EditText.setText(String.format(" %0.2f", twentyPercentTotal));		
		
	}
	
	private void updateCustom() {
		
		customTipTextView.setText(currentCustomPercent+"%");
		
		double customTipAmount = currentBillTotal * currentCustomPercent * .01;
		double customTotalAmount = currentBillTotal + customTipAmount;
		
		tipCustomEditText.setText(String.format(" %0.2f", customTipAmount));
		totalCustomEditText.setText(String.format(" %0.2f", customTotalAmount));
		
	}
	
	
	
    @Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		
		outState.putDouble(BILL_TOTAL, currentBillTotal);
		outState.putInt(CUSTOM_PERCENT, currentCustomPercent);
		
	}

    

}



У меня никак не срабатывает следующий участок кода

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
private SeekBar.OnSeekBarChangeListener customSeekBarListener = new SeekBar.OnSeekBarChangeListener() {
		
		@Override
		public void onStopTrackingTouch(SeekBar seekBar) {	
			
		}
		
		@Override
		public void onStartTrackingTouch(SeekBar seekBar) {			
			
		}
		
		@Override
		public void onProgressChanged(SeekBar seekBar, int progress,
				boolean fromUser) {
		    //currentCustomPercent = seekBar.getProgress();
		    customTipTextView.setText(String.valueOf(seekBar.getProgress()));
		    //updateCustom();
		}
	};	



То есть при прокрутке SeekBar у меня должно меняться значение в TextView, а оно никак не меняется, что не так?

P.S: Я новичок в программировании под Android
...
Рейтинг: 0 / 0
Android программирование
    #38338341
Aina2008
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Спасибо за внимание
Уже разорался
Тем можно закрыть
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / Android [игнор отключен] [закрыт для гостей] / Android программирование
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]