<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум Александра Климова — Светофор]]></title>
	<link rel="self" href="http://forum.alexanderklimov.ru/extern.php?action=feed&amp;tid=7&amp;type=atom" />
	<updated>2022-01-26T19:30:03Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.alexanderklimov.ru/viewtopic.php?id=7</id>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1191#p1191" />
			<content type="html"><![CDATA[<p>Я предпочитаю по старинке через findViewById. Но можно и через view bindings</p>]]></content>
			<author>
				<name><![CDATA[alexander.klimoff]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2</uri>
			</author>
			<updated>2022-01-26T19:30:03Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1191#p1191</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1190#p1190" />
			<content type="html"><![CDATA[<p>Правильно понимаю, что на данный момент лучше выполнять задания через view bindings так как Kotlin Android Extensions устарел?</p>]]></content>
			<author>
				<name><![CDATA[HellDHound]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2176</uri>
			</author>
			<updated>2022-01-26T16:04:52Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1190#p1190</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1184#p1184" />
			<content type="html"><![CDATA[<p>Почему бы за места&nbsp; mConstraintLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.greenColor));<br />не использовать mConstraintLayout.setBackgroundResource(R.color.greenColor);<br />тоже работает и проще.<br />В чем разница?</p>]]></content>
			<author>
				<name><![CDATA[Fashick5]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2078</uri>
			</author>
			<updated>2020-11-06T08:58:29Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1184#p1184</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1177#p1177" />
			<content type="html"><![CDATA[<p>вот так на Kotlin(может я ошибку написал, но работает)</p><p>package com.android.trafficlight</p><p>import androidx.appcompat.app.AppCompatActivity<br />import android.os.Bundle</p><br /><p>import androidx.core.content.ContextCompat<br />import kotlinx.android.synthetic.main.activity_main.*</p><br /><br /><br /><p>class MainActivity : AppCompatActivity() {</p><br /><p>&nbsp; &nbsp; override fun onCreate(savedInstanceState: Bundle?) {<br />&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState)<br />&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_main)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; buttonRed.setOnClickListener {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textView.setText(R.string.Red)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; constraintLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.redColor))<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; buttonYellow.setOnClickListener {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textView.setText(R.string.Yellow)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; constraintLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.yellowColor))<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; buttonGreen.setOnClickListener {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textView.setText(R.string.Green)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; constraintLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.greenColor))<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; }</p><br /><p>}</p>]]></content>
			<author>
				<name><![CDATA[abstred]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2017</uri>
			</author>
			<updated>2020-01-31T11:56:50Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1177#p1177</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1170#p1170" />
			<content type="html"><![CDATA[<p>Спасибо.<br />Ваши статьи помогают.</p><p>Так проще всего если у каждой заранее задать цвет кнопке</p><p> public void onClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; Button myB = (Button) view;<br />&nbsp; &nbsp; &nbsp; &nbsp; basicView.setBackground(myB.getBackground());<br />&nbsp; &nbsp; &nbsp; &nbsp; colorDeskripton.setText(myB.getText());<br />&nbsp; &nbsp; }</p>]]></content>
			<author>
				<name><![CDATA[dmitrybarynov]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2003</uri>
			</author>
			<updated>2019-12-27T19:43:27Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1170#p1170</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1082#p1082" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ellenripley4 wrote:</cite><blockquote><p>Почему в режиме разметки, когда я ставлю фон своему ConstrainLayout через свойство Background, у меня меняется фон и у всех кнопок тоже?</p></blockquote></div><p>У кнопок проверьте Background - не наследуется ли от разметки?</p>]]></content>
			<author>
				<name><![CDATA[NeferSky]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1445</uri>
			</author>
			<updated>2018-03-29T11:27:47Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1082#p1082</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1081#p1081" />
			<content type="html"><![CDATA[<p>Почему в режиме разметки, когда я ставлю фон своему ConstrainLayout через свойство Background, у меня меняется фон и у всех кнопок тоже?</p>]]></content>
			<author>
				<name><![CDATA[ellenripley4]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1639</uri>
			</author>
			<updated>2018-03-29T07:41:40Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1081#p1081</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1018#p1018" />
			<content type="html"><![CDATA[<p>Вобщем после того как изменил в кнопках обработчик, перестало робить приложение, долго ломал голову что не так, а оказалось что создался файлик activity_main.xml (v21)&nbsp; в соседней папке дубль <a href="http://prntscr.com/hoo0zt">http://prntscr.com/hoo0zt</a><br />Вопрос зачем он создается и почему не видит изменение в родном файле? хотя при создании родного заполняется один в один.</p><p>Неужели при правке в дальнейшем надо искать все файлы дубли для других версий и обновлять код и вних тоже ?<br />Или есть какая то синхронизация ?</p>]]></content>
			<author>
				<name><![CDATA[permsk]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1561</uri>
			</author>
			<updated>2017-12-17T16:07:01Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1018#p1018</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=932#p932" />
			<content type="html"><![CDATA[<p>Спасибо, разобрался.</p>]]></content>
			<author>
				<name><![CDATA[Across]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1506</uri>
			</author>
			<updated>2017-10-10T03:30:25Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=932#p932</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=931#p931" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Across wrote:</cite><blockquote><p>Не хочет компилировать ни мой код ни код с урока (полностью копировал). Выдет вот такую ошибку.</p><p>Error:(21, 65) error: cannot find symbol variable constraintLayout<br />Error:(21, 65) error: cannot find symbol variable constraintLayout<br />Error:Execution failed for task &#039;:app:compileDebugJavaWithJavac&#039;.<br />&gt; Compilation failed; see the compiler error output for details.</p><p>В этой части кода:<br />mConstraintLayout = (ConstraintLayout) findViewById(R.id.constraintLayout); &lt;------- в студии последнее слово подчеркнуто красным<br />mInfoTextView = (TextView) findViewById(R.id.textViewInfo);&nbsp; &lt;-------- в студии последнее слово подчеркнуто красным</p><p>В чем может быть проблема?<br />За ранее благодарен</p></blockquote></div><p>В разметке смотрите, как именован layout и textView, по-видимому, Вы их там не переименовали.</p>]]></content>
			<author>
				<name><![CDATA[NeferSky]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1445</uri>
			</author>
			<updated>2017-10-09T04:46:12Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=931#p931</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=929#p929" />
			<content type="html"><![CDATA[<p>Не хочет компилировать ни мой код ни код с урока (полностью копировал). Выдет вот такую ошибку.</p><p>Error:(21, 65) error: cannot find symbol variable constraintLayout<br />Error:(21, 65) error: cannot find symbol variable constraintLayout<br />Error:Execution failed for task &#039;:app:compileDebugJavaWithJavac&#039;.<br />&gt; Compilation failed; see the compiler error output for details.</p><div class="codebox"><pre><code>package across.helloworld;

import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private ConstraintLayout mConstraintLayout;
    private TextView mInfoTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mConstraintLayout = (ConstraintLayout) findViewById(R.id.constraintLayout);
        mInfoTextView = (TextView) findViewById(R.id.textViewInfo);

    }

    public void onRedButtonClick(View view) {
        mInfoTextView.setText(R.string.red);
        mConstraintLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.redColor));
}

    public void onYelloButtonClick(View view) {
        mInfoTextView.setText(R.string.red);
        mConstraintLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.yellowColor));
    }

    public void onGreenButtonClick(View view) {
        mInfoTextView.setText(R.string.red);
        mConstraintLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.greenColor));
    }
}</code></pre></div><p>В этой части кода:<br />mConstraintLayout = (ConstraintLayout) findViewById(R.id.constraintLayout); &lt;------- в студии последнее слово подчеркнуто красным<br />mInfoTextView = (TextView) findViewById(R.id.textViewInfo);&nbsp; &lt;-------- в студии последнее слово подчеркнуто красным</p><p>В чем может быть проблема?<br />Заранее благодарен</p>]]></content>
			<author>
				<name><![CDATA[Across]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1506</uri>
			</author>
			<updated>2017-10-09T01:44:28Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=929#p929</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=887#p887" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>NeferSky wrote:</cite><blockquote><p>Хороший подход, что Вас смущает?))</p></blockquote></div><p>ну главное, что прием работает и задание из урока выполнил ПО СВОЕМУ,<br />но все таки если событий будет много то этот подход не подойдет. лучше будет как в примере из статьи &quot;кнопка&quot;, которую кстати прочитал после выполнения задания ))</p>]]></content>
			<author>
				<name><![CDATA[ramazan0504]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1493</uri>
			</author>
			<updated>2017-08-28T14:42:14Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=887#p887</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=883#p883" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ramazan0504 wrote:</cite><blockquote><p>а я сделал так и тоже работает, сколько ударов по голове я заслуживаю за такой подход?</p></blockquote></div><p>Хороший подход, что Вас смущает?))</p>]]></content>
			<author>
				<name><![CDATA[NeferSky]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1445</uri>
			</author>
			<updated>2017-08-28T11:18:54Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=883#p883</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=882#p882" />
			<content type="html"><![CDATA[<p>а я сделал так и тоже работает, сколько ударов по голове я заслуживаю за такой подход?</p><p>public class VoronActivity extends AppCompatActivity {<br />&nbsp; &nbsp; private ConstraintLayout layout;<br />&nbsp; &nbsp; private TextView textView;<br />&nbsp; &nbsp; private Button redButton;<br />&nbsp; &nbsp; private Button greenButton;<br />&nbsp; &nbsp; private Button yellowButton;</p><p>&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {<br />&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);<br />&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_voron);<br />&nbsp; &nbsp; &nbsp; &nbsp; layout = (ConstraintLayout)findViewById(R.id.layout);<br />&nbsp; &nbsp; &nbsp; &nbsp; textView = (TextView)findViewById(R.id.textView);\</p><p>&nbsp; &nbsp; &nbsp; &nbsp; redButton = (Button)findViewById(R.id.button_red);<br />&nbsp; &nbsp; &nbsp; &nbsp; greenButton = (Button)findViewById(R.id.button_green);<br />&nbsp; &nbsp; &nbsp; &nbsp; yellowButton = (Button)findViewById(R.id.button_yellow);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; onClick(redButton,R.string.red, R.color.colorRed);<br />&nbsp; &nbsp; &nbsp; &nbsp; onClick(greenButton,R.string.green, R.color.colorGreen);<br />&nbsp; &nbsp; &nbsp; &nbsp; onClick(yellowButton,R.string.yellow, R.color.colorYellow);</p><p>&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onClick(Button button, final int resString, final int color) {<br />&nbsp; &nbsp; &nbsp; &nbsp; button.setOnClickListener(new View.OnClickListener() {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textView.setText(resString);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout.setBackgroundColor(ContextCompat.getColor(VoronActivity.this, color));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; }<br />}</p>]]></content>
			<author>
				<name><![CDATA[ramazan0504]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1493</uri>
			</author>
			<updated>2017-08-28T10:44:44Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=882#p882</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Светофор]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=836#p836" />
			<content type="html"><![CDATA[<p>Точно, благодарю! <br />Я не специально редактировал, случайно как-то получилось, сам не понял как.</p>]]></content>
			<author>
				<name><![CDATA[frods]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1468</uri>
			</author>
			<updated>2017-06-01T17:20:47Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=836#p836</id>
		</entry>
</feed>
