<?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=11&amp;type=atom" />
	<updated>2020-01-01T12:12:08Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.alexanderklimov.ru/viewtopic.php?id=11</id>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1171#p1171" />
			<content type="html"><![CDATA[<p>Добрый день,</p><p>по методам которые вызываются во время поворота экрана написал простенькую программу.<br />но вот странно при повороте отображаются не все события<br />activity xml:<br /></p><div class="codebox"><pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    tools:context=&quot;.MainActivity&quot;&gt;

    &lt;LinearLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;match_parent&quot;
        android:orientation=&quot;vertical&quot;
        android:padding=&quot;20dp&quot;
        app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
        app:layout_constraintEnd_toEndOf=&quot;parent&quot;
        app:layout_constraintStart_toStartOf=&quot;parent&quot;
        app:layout_constraintTop_toTopOf=&quot;parent&quot;&gt;

        &lt;TableLayout
            android:layout_width=&quot;match_parent&quot;
            android:layout_height=&quot;wrap_content&quot;&gt;

            &lt;TableRow
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;match_parent&quot;&gt;

                &lt;CheckBox
                    android:id=&quot;@+id/wasPause&quot;
                    android:layout_width=&quot;wrap_content&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:clickable=&quot;false&quot;

                    android:text=&quot;@string/wasPause&quot; /&gt;
            &lt;/TableRow&gt;

            &lt;TableRow
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;match_parent&quot;&gt;

                &lt;CheckBox
                    android:id=&quot;@+id/wasStop&quot;
                    android:layout_width=&quot;wrap_content&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:clickable=&quot;false&quot;

                    android:text=&quot;@string/wasStop&quot; /&gt;
            &lt;/TableRow&gt;

            &lt;TableRow
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;match_parent&quot;&gt;

                &lt;CheckBox
                    android:id=&quot;@+id/wasDestroy&quot;
                    android:layout_width=&quot;wrap_content&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:clickable=&quot;false&quot;

                    android:text=&quot;@string/wasDestroy&quot; /&gt;
            &lt;/TableRow&gt;

            &lt;TableRow
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;match_parent&quot;&gt;

                &lt;CheckBox
                    android:id=&quot;@+id/wasCreate&quot;
                    android:layout_width=&quot;wrap_content&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:clickable=&quot;false&quot;

                    android:text=&quot;@string/wasCreate&quot; /&gt;

            &lt;/TableRow&gt;

            &lt;TableRow
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;match_parent&quot;&gt;

                &lt;CheckBox
                    android:id=&quot;@+id/wasStart&quot;
                    android:layout_width=&quot;wrap_content&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:clickable=&quot;false&quot;

                    android:text=&quot;@string/wasStart&quot; /&gt;
            &lt;/TableRow&gt;

            &lt;TableRow
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;match_parent&quot;&gt;

                &lt;CheckBox
                    android:id=&quot;@+id/wasResume&quot;
                    android:layout_width=&quot;wrap_content&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:clickable=&quot;false&quot;

                    android:text=&quot;@string/wasResume&quot; /&gt;
            &lt;/TableRow&gt;

            &lt;TableRow
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;match_parent&quot;&gt;

                &lt;CheckBox
                    android:id=&quot;@+id/wasSaveInstanceState&quot;
                    android:layout_width=&quot;wrap_content&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:clickable=&quot;false&quot;

                    android:text=&quot;@string/wasSaveInstanceState&quot; /&gt;
            &lt;/TableRow&gt;
        &lt;/TableLayout&gt;

        &lt;Button
            android:id=&quot;@+id/clearBoxes&quot;
            android:layout_width=&quot;match_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;@string/clearBoxes&quot;
            android:onClick=&quot;clearBoxes&quot;/&gt;

    &lt;/LinearLayout&gt;

&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;</code></pre></div><p>Activity class:<br /></p><div class="codebox"><pre><code>import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;

public class MainActivity extends AppCompatActivity {

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

        CheckBox mBox = findViewById(R.id.wasCreate);
        mBox.setChecked(true);
    }

    @Override
    protected void onStop() {
        super.onStop();

        CheckBox mBox = findViewById(R.id.wasStop);
        mBox.setChecked(true);
    }

    @Override
    protected void onPause() {
        super.onPause();

        CheckBox mBox = findViewById(R.id.wasPause);
        mBox.setChecked(true);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        CheckBox mBox = findViewById(R.id.wasDestroy);
        mBox.setChecked(true);
    }

    @Override
    protected void onStart() {
        super.onStart();

        CheckBox mBox = findViewById(R.id.wasStart);
        mBox.setChecked(true);
    }

    @Override
    protected void onResume() {
        super.onResume();

        CheckBox mBox = findViewById(R.id.wasResume);
        mBox.setChecked(true);
    }

    @Override
    protected void onSaveInstanceState(@NonNull Bundle outState) {
        super.onSaveInstanceState(outState);

        CheckBox mBox = findViewById(R.id.wasSaveInstanceState);
        mBox.setChecked(true);
    }

    public void clearBoxes(View view) {

        int idBoxes[] = { R.id.wasSaveInstanceState,
                R.id.wasPause, R.id.wasDestroy,
                R.id.wasCreate,R.id.wasResume,
                R.id.wasStart, R.id.wasStop};

        for (int idBox: idBoxes) {
            CheckBox mBox = findViewById(idBox);
            mBox.setChecked(false);
        }
    }
}</code></pre></div><p>А в результате только это после поворота:<br /><span class="postimg"><img src="https://a.radikal.ru/a01/2001/c8/14845e85ddf9.png" alt="screen" /></span><br />Почему так?</p>]]></content>
			<author>
				<name><![CDATA[dmitrybarynov]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2003</uri>
			</author>
			<updated>2020-01-01T12:12:08Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1171#p1171</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1073#p1073" />
			<content type="html"><![CDATA[<p>Здравствуйте!<br />У меня возникла такая проблема при повороте экрана на 90 и -90 градусов, все поворачивается нормально. Но когда поворачиваю на 180 градусов ориентация экрана не меняется. В чем проблема?</p>]]></content>
			<author>
				<name><![CDATA[aganinrinat]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1631</uri>
			</author>
			<updated>2018-03-12T22:28:23Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1073#p1073</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1057#p1057" />
			<content type="html"><![CDATA[<p>Это точно работает на планшете Nexus 2013, только 90 и -90 работают наоборот. Другая система отсчета. А на телефонах и эмуляторах действительно у большинства это не сработает. Поэтому не стоит полагаться на этот код.</p>]]></content>
			<author>
				<name><![CDATA[alexander.klimoff]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2</uri>
			</author>
			<updated>2018-02-06T20:15:46Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1057#p1057</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1056#p1056" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alexander.klimoff wrote:</cite><blockquote><p>Возможно, телефон не поддерживает.</p></blockquote></div><p>Возможно, но я перепробовал смартфон и несколько эмуляторов.</p>]]></content>
			<author>
				<name><![CDATA[dimabuslaev]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1562</uri>
			</author>
			<updated>2018-02-06T12:45:01Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1056#p1056</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1053#p1053" />
			<content type="html"><![CDATA[<p>Возможно, телефон не поддерживает.</p>]]></content>
			<author>
				<name><![CDATA[alexander.klimoff]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2</uri>
			</author>
			<updated>2018-01-24T10:45:15Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1053#p1053</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=1046#p1046" />
			<content type="html"><![CDATA[<p>Здравствуйте! <br />Почему getRotation не правильно определяется? <br />При повороте вправо выдается: &quot;повернули на 90 градусов против часовой стрелки&quot;, тоже самое при любом другом положении, кроме default.</p><p>Вот код:</p><p>package ru.buslay.rotateme;</p><p>import android.content.res.Configuration;<br />import android.support.v7.app.AppCompatActivity;<br />import android.os.Bundle;<br />import android.view.Surface;<br />import android.view.View;<br />import android.widget.Toast;</p><p>public class MainActivity extends AppCompatActivity {<br />&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_main);</p><p>&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; private String getScreenOrientation(){<br />&nbsp; &nbsp; &nbsp; &nbsp; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &quot;Портретная ориентация&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &quot;Альбомная ориентация&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &quot;&quot;;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; private String getRotateOrientation() {<br />&nbsp; &nbsp; &nbsp; &nbsp; int rotate = getWindowManager().getDefaultDisplay().getRotation();</p><p>&nbsp; &nbsp; &nbsp; &nbsp; switch (rotate){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case Surface.ROTATION_0:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &quot;Не поворачивали&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case Surface.ROTATION_90:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &quot;Повернули на 90 градусов по часовой стрелке&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case Surface.ROTATION_180:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &quot;Повернули на 180 градусов&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case Surface.ROTATION_270:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &quot;Повернули на 90 градусов против часовой стрелки&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &quot;Не понятно&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void push(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; Toast toast = Toast.makeText(getApplicationContext(),getScreenOrientation(),Toast.LENGTH_SHORT);<br />&nbsp; &nbsp; &nbsp; &nbsp; toast.show();<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; public void pushItReal(View view){<br />&nbsp; &nbsp; &nbsp; &nbsp; Toast toast = Toast.makeText(getApplicationContext(),getRotateOrientation(),Toast.LENGTH_LONG);<br />&nbsp; &nbsp; &nbsp; &nbsp; toast.show();<br />&nbsp; &nbsp; }<br />}</p>]]></content>
			<author>
				<name><![CDATA[dimabuslaev]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1562</uri>
			</author>
			<updated>2018-01-21T14:12:30Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=1046#p1046</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=982#p982" />
			<content type="html"><![CDATA[<p>Нет. Добавьте кнопку в разметку и в режиме Design посмотрите у кнопки атрибут Style. Кнопка может быть разной внешне.</p>]]></content>
			<author>
				<name><![CDATA[alexander.klimoff]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2</uri>
			</author>
			<updated>2017-11-16T14:46:56Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=982#p982</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=981#p981" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>alexander.klimoff wrote:</cite><blockquote><p>Это не ошибка (иначе бы не запустилось), а предупреждение. Просто советуют поменять стиль кнопки. Если вас устраивает, то оставляйте.</p></blockquote></div><p>Вы об этом<br />---<br />Отдельно стоит отметить создание стиля для кнопки. У кнопки есть несколько состояний - обычное, в фокусе, нажатое, нажатое с фокусом. Поэтому для кнопки нужно создать четыре отдельных стиля, чтобы кнопка выглядела профессионально.<br />----<br />??</p>]]></content>
			<author>
				<name><![CDATA[kirill_nn]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1489</uri>
			</author>
			<updated>2017-11-16T12:34:24Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=981#p981</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=977#p977" />
			<content type="html"><![CDATA[<p>Это ничем не отличается от вашего mConstraintLayout.setBackgroundColor(getResources().getColor(R.color.colorRed));</p>]]></content>
			<author>
				<name><![CDATA[alexander.klimoff]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2</uri>
			</author>
			<updated>2017-11-14T17:21:00Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=977#p977</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=974#p974" />
			<content type="html"><![CDATA[<p>2 alexander.klimoff спасибо! Прочитаю обязательно. Пока сделал через &quot;костылик&quot;</p><p>import android.app.Activity;<br />import android.os.Bundle;<br />import android.support.constraint.ConstraintLayout;<br />import android.view.View;<br />import android.widget.TextView;</p><p>public class light extends Activity {<br />&nbsp; &nbsp; private ConstraintLayout mConstraintLayout;<br />&nbsp; &nbsp; private TextView mInfoTextView;<br />&nbsp; &nbsp; private static final String KEY_COLOR = &quot;COLOR&quot;;<br />&nbsp; &nbsp; private static String COLOR_STRING_SAVE = &quot;&quot;;</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_light);<br />&nbsp; &nbsp; &nbsp; &nbsp; mConstraintLayout = findViewById(R.id.layout);<br />&nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView = findViewById(R.id.textView);<br />&nbsp; &nbsp; &nbsp; &nbsp; if (savedInstanceState != null) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (savedInstanceState.getString(KEY_COLOR, COLOR_STRING_SAVE).equals(&quot;red&quot;)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; red();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else if (savedInstanceState.getString(KEY_COLOR, COLOR_STRING_SAVE).equals(&quot;yellow&quot;)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yellow();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else if (savedInstanceState.getString(KEY_COLOR, COLOR_STRING_SAVE).equals(&quot;green&quot;)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; green();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else { //for savedInstanceState error<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; red();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; } else {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; red();<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onButtonRedClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; red();<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onButtonYellowClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; yellow();<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onButtonGreenClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; green();<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void red() {<br />&nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(R.string.buttonRed);<br />&nbsp; &nbsp; &nbsp; &nbsp; mConstraintLayout.setBackgroundColor(getResources().getColor(R.color.colorRed));<br />&nbsp; &nbsp; &nbsp; &nbsp; COLOR_STRING_SAVE = &quot;red&quot;;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void yellow() {<br />&nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(R.string.buttonYellow);<br />&nbsp; &nbsp; &nbsp; &nbsp; mConstraintLayout.setBackgroundColor(getResources().getColor(R.color.colorYellow));<br />&nbsp; &nbsp; &nbsp; &nbsp; COLOR_STRING_SAVE = &quot;yellow&quot;;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void green() {<br />&nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(R.string.buttonGreen);<br />&nbsp; &nbsp; &nbsp; &nbsp; mConstraintLayout.setBackgroundColor(getResources().getColor(R.color.colorGreen));<br />&nbsp; &nbsp; &nbsp; &nbsp; COLOR_STRING_SAVE = &quot;green&quot;;<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; protected void onSaveInstanceState(Bundle outState) {<br />&nbsp; &nbsp; &nbsp; &nbsp; super.onSaveInstanceState(outState);<br />&nbsp; &nbsp; &nbsp; &nbsp; outState.putString(KEY_COLOR, COLOR_STRING_SAVE);<br />&nbsp; &nbsp; }<br />}</p><p>Прочитал.<br />Вы про способ</p><p>int myRedColor = activity.getResourses.getColor(R.color.red); // получаем значение красного цвета</p><p>Запомнить цвет как Int?? интересненько... нада запомнить :-)<br />PS никогда не думал, что просто переворот девайса - это куча алгоритмов, и действий :-)<br />А мне кстати мой&nbsp; способ через &quot;костылик&quot; нравиться :-)</p>]]></content>
			<author>
				<name><![CDATA[kirill_nn]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1489</uri>
			</author>
			<updated>2017-11-14T13:02:05Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=974#p974</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=973#p973" />
			<content type="html"><![CDATA[<p><a href="http://developer.alexanderklimov.ru/android/theory/resources.php#color">http://developer.alexanderklimov.ru/and … .php#color</a></p>]]></content>
			<author>
				<name><![CDATA[alexander.klimoff]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2</uri>
			</author>
			<updated>2017-11-14T10:05:11Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=973#p973</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=972#p972" />
			<content type="html"><![CDATA[<p>А как сохранить ресурс?? что бы при смене Ориентации экрана сохранялся цвет фона??<br />С текстом кнопки разобрался... а вот что делать с цветом фона, придумать не могу...<br />Переделываю Светофор под &quot;повороты экрана&quot; :-)<br /><a href="https://github.com/KirillNN/TrafficLight">https://github.com/KirillNN/TrafficLight</a></p><p>public class light extends Activity {<br />&nbsp; &nbsp; private ConstraintLayout mConstraintLayout;<br />&nbsp; &nbsp; private TextView mInfoTextView;<br />&nbsp; &nbsp; private static final String KEY_COLOR = &quot;COLOR&quot;;<br />&nbsp; &nbsp; private static final String KEY_BUTTON = &quot;BUTTON&quot;;<br />&nbsp; &nbsp; private static String COLOR_STRING_SAVE = &quot;&quot;;</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_light);<br />&nbsp; &nbsp; &nbsp; &nbsp; mConstraintLayout = findViewById(R.id.layout);<br />&nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView = findViewById(R.id.textView);<br />&nbsp; &nbsp; &nbsp; &nbsp; mConstraintLayout.setBackgroundColor(getResources().getColor(R.color.colorRed));<br />&nbsp; &nbsp; &nbsp; &nbsp; if (savedInstanceState != null) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(savedInstanceState.getString(KEY_COLOR, COLOR_STRING_SAVE));<br />&nbsp; &nbsp; &nbsp; &nbsp; } else {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(R.string.buttonRed);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onButtonRedClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(R.string.buttonRed);<br />&nbsp; &nbsp; &nbsp; &nbsp; mConstraintLayout.setBackgroundColor(getResources().getColor(R.color.colorRed));<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onButtonYellowClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(R.string.buttonYellow);<br />&nbsp; &nbsp; &nbsp; &nbsp; mConstraintLayout.setBackgroundColor(getResources().getColor(R.color.colorYellow));<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onButtonGreenClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(R.string.buttonGreen);<br />&nbsp; &nbsp; &nbsp; &nbsp; mConstraintLayout.setBackgroundColor(getResources().getColor(R.color.colorGreen));<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; protected void onSaveInstanceState(Bundle outState) {<br />&nbsp; &nbsp; &nbsp; &nbsp; super.onSaveInstanceState(outState);<br />&nbsp; &nbsp; &nbsp; &nbsp; COLOR_STRING_SAVE = mInfoTextView.getText().toString();<br />&nbsp; &nbsp; &nbsp; &nbsp; outState.putString(KEY_BUTTON, COLOR_STRING_SAVE);</p><p>&nbsp; &nbsp; }<br />}</p>]]></content>
			<author>
				<name><![CDATA[kirill_nn]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1489</uri>
			</author>
			<updated>2017-11-14T09:07:34Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=972#p972</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=968#p968" />
			<content type="html"><![CDATA[<p>Это не ошибка (иначе бы не запустилось), а предупреждение. Просто советуют поменять стиль кнопки. Если вас устраивает, то оставляйте.</p>]]></content>
			<author>
				<name><![CDATA[alexander.klimoff]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2</uri>
			</author>
			<updated>2017-11-13T10:53:55Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=968#p968</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=967#p967" />
			<content type="html"><![CDATA[<p>Начинаю делать данный урок... Создал Landskape ориентацию... скопировал код... вернул, что бы создать автоматом в Andriod Studio Создал автоматом, долго копался, как все таки расставить кнопки, как я хочу (без копирования когда), расставил<br />Выдает ошибку - button should be borderless, нор при этом, все отлично работает, отображается как я хочу...<br />Если не трудно объясните что не так...<br /><a href="https://github.com/KirillNN/Orienration">https://github.com/KirillNN/Orienration</a><br />Заранее благодарен :-)</p>]]></content>
			<author>
				<name><![CDATA[kirill_nn]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=1489</uri>
			</author>
			<updated>2017-11-12T06:39:23Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=967#p967</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Ориентация]]></title>
			<link rel="alternate" href="http://forum.alexanderklimov.ru/viewtopic.php?pid=863#p863" />
			<content type="html"><![CDATA[<p>Уроки существуют уже пять лет и по ним выучилось тысячи человек. Если у вас что-то не получается, значит вы что-то не так делаете. Я не экстрасенс и определить ваши ошибки по вашим сообщениям не в состоянии. Можете описать свою проблему в письме, попробуем разобраться.</p>]]></content>
			<author>
				<name><![CDATA[alexander.klimoff]]></name>
				<uri>http://forum.alexanderklimov.ru/profile.php?id=2</uri>
			</author>
			<updated>2017-08-05T09:49:02Z</updated>
			<id>http://forum.alexanderklimov.ru/viewtopic.php?pid=863#p863</id>
		</entry>
</feed>
