<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Форум Александра Климова — Щелчок кнопки/Счётчик ворон]]></title>
		<link>http://forum.alexanderklimov.ru/viewtopic.php?id=6</link>
		<atom:link href="http://forum.alexanderklimov.ru/extern.php?action=feed&amp;tid=6&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Щелчок кнопки/Счётчик ворон.]]></description>
		<lastBuildDate>Tue, 20 Nov 2018 11:08:24 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=1136#p1136</link>
			<description><![CDATA[<p>Я зарезервировал статичную&nbsp; переменную private <strong>static</strong> int mCount = 0; <br />В apk на смартфоне, после выхода из программы (кнопка назад на аппарате) запускаю программу снова и mCout не обнулилась. Так и должно быть, из-за того, что static? Сборщик мусора ее не собрал, т.к. она не 0?<br />System.exit(0) на самопальную кнопку выхода обнуляет переменную. Но все равно, текущее activity висит в памяти андроида.</p>]]></description>
			<author><![CDATA[null@example.com (MonoLife)]]></author>
			<pubDate>Tue, 20 Nov 2018 11:08:24 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=1136#p1136</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=1089#p1089</link>
			<description><![CDATA[<p>Проблема в 15 строчке кода MainActivity&nbsp; : &quot;at me.brainstory.ravencounternew.MainActivity.&lt;init&gt;(MainActivity.java:15)&quot;&nbsp; </p><p>Инициализируйте свое текстовое поле mInfoTextView = findViewById(R.id.textView)&nbsp; в методе onCreate.</p>]]></description>
			<author><![CDATA[null@example.com (mihael)]]></author>
			<pubDate>Wed, 11 Apr 2018 10:58:35 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=1089#p1089</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=1088#p1088</link>
			<description><![CDATA[<p>Добрый день.<br />Сделал всё по уроку. Но при попытке запуска приложения через эмулятор выскакивает сообщение о том, что приложение не может быть запущено. При установке apk файла на телефон приложение тоже не открывается.</p><p>Acivity Main:<br />&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />&lt;android.support.constraint.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br />&nbsp; &nbsp; xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br />&nbsp; &nbsp; xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br />&nbsp; &nbsp; android:layout_width=&quot;match_parent&quot;<br />&nbsp; &nbsp; android:layout_height=&quot;match_parent&quot;<br />&nbsp; &nbsp; tools:context=&quot;.MainActivity&quot;&gt;</p><p>&nbsp; &nbsp; &lt;Button<br />&nbsp; &nbsp; &nbsp; &nbsp; android:id=&quot;@+id/button&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginStart=&quot;113dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginTop=&quot;166dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:onClick=&quot;onClick&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:text=&quot;Поздороваться&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintStart_toStartOf=&quot;parent&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;</p><p>&nbsp; &nbsp; &lt;TextView<br />&nbsp; &nbsp; &nbsp; &nbsp; android:id=&quot;@+id/textView&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginStart=&quot;163dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginTop=&quot;289dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintStart_toStartOf=&quot;parent&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;</p><p>&nbsp; &nbsp; &lt;Button<br />&nbsp; &nbsp; &nbsp; &nbsp; android:id=&quot;@+id/button_counter&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginStart=&quot;115dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginTop=&quot;30dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:text=&quot;Считаем ворон&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintStart_toStartOf=&quot;parent&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintTop_toBottomOf=&quot;@+id/textView&quot; /&gt;</p><p>&nbsp; &nbsp; &lt;Button<br />&nbsp; &nbsp; &nbsp; &nbsp; android:id=&quot;@+id/button_counterCats&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginStart=&quot;116dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginTop=&quot;26dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:text=&quot;Считаем котов&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintStart_toStartOf=&quot;parent&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintTop_toBottomOf=&quot;@+id/textView2&quot; /&gt;</p><p>&nbsp; &nbsp; &lt;TextView<br />&nbsp; &nbsp; &nbsp; &nbsp; android:id=&quot;@+id/textView2&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height=&quot;wrap_content&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginStart=&quot;163dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginTop=&quot;410dp&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintStart_toStartOf=&quot;parent&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;<br />&lt;/android.support.constraint.ConstraintLayout&gt;</p><br /><br /><p>Java:<br />package me.brainstory.ravencounter;</p><p>import android.app.Activity;<br />import android.os.Bundle;<br />import android.view.View;<br />import android.widget.Button;<br />import android.widget.TextView;</p><br /><p>public class MainActivity extends Activity {</p><br /><p>&nbsp; &nbsp; private int mCount = 0;<br />&nbsp; &nbsp; private int mCatsCount = 0;<br />&nbsp; &nbsp; TextView mInfoTextView = findViewById(R.id.textView);</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_main);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Button mCrowsCounterButton = findViewById(R.id.button_counter);<br />&nbsp; &nbsp; &nbsp; &nbsp; mCrowsCounterButton.setOnClickListener(new View.OnClickListener() {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(&quot;Я насчитал &quot; + ++mCount + &quot; ворон&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; });</p><p>&nbsp; &nbsp; &nbsp; &nbsp; final TextView mInfoCatsView = findViewById(R.id.textView2);<br />&nbsp; &nbsp; &nbsp; &nbsp; Button mCatsCounterButton = findViewById(R.id.button_counterCats);<br />&nbsp; &nbsp; &nbsp; &nbsp; mCatsCounterButton.setOnClickListener(new View.OnClickListener() {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mInfoCatsView.setText(&quot;Я насчитал &quot; + ++mCatsCount + &quot; ворон&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(&quot;Hello Kitty!&quot;);<br />&nbsp; &nbsp; }<br />}</p><br /><p>Error Log:<br />04/08 15:02:06: Launching app<br />$ adb install-multiple -r -t D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\resources\instant-run\debug\resources-debug.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\dep\dependencies.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_0.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_1.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_2.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_3.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_4.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_5.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_6.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_7.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_8.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\split-apk\debug\slices\slice_9.apk D:\AndroidStudioProjects\RavenCounterNew\app\build\intermediates\instant-run-apk\debug\app-debug.apk <br />Split APKs installed<br />$ adb shell am start -n &quot;me.brainstory.ravencounternew/me.brainstory.ravencounternew.MainActivity&quot; -a android.intent.action.MAIN -c android.intent.category.LAUNCHER<br />Client not ready yet..Waiting for process to come online<br />Connected to process 6334 on device emulator-5554<br />Capturing and displaying logcat messages from application. This behavior can be disabled in the &quot;Logcat output&quot; section of the &quot;Debugger&quot; settings page.<br />I/InstantRun: starting instant run server: is main process<br />D/AndroidRuntime: Shutting down VM<br />E/AndroidRuntime: FATAL EXCEPTION: main<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Process: me.brainstory.ravencounternew, PID: 6334<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{me.brainstory.ravencounternew/me.brainstory.ravencounternew.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method &#039;android.view.View android.view.Window.findViewById(int)&#039; on a null object reference<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.-wrap11(Unknown Source:0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Handler.dispatchMessage(Handler.java:106)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Looper.loop(Looper.java:164)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.main(ActivityThread.java:6494)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Native Method)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Caused by: java.lang.NullPointerException: Attempt to invoke virtual method &#039;android.view.View android.view.Window.findViewById(int)&#039; on a null object reference<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.Activity.findViewById(Activity.java:2578)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at me.brainstory.ravencounternew.MainActivity.&lt;init&gt;(MainActivity.java:15)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at java.lang.Class.newInstance(Native Method)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.Instrumentation.newActivity(Instrumentation.java:1174)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.-wrap11(Unknown Source:0) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Handler.dispatchMessage(Handler.java:106) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Looper.loop(Looper.java:164) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.main(ActivityThread.java:6494) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Native Method) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) <br />Application terminated.</p><br /><p>В чем может быть проблема?<br />Спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (Amberalex)]]></author>
			<pubDate>Sun, 08 Apr 2018 14:15:25 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=1088#p1088</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=1041#p1041</link>
			<description><![CDATA[<p>вы сами попробуйте рассуждать логически. Если текст выводится не там, где вы ожидате, значит вы напутали с компонентами. Проверьте еще раз в своем макете, правильно ли вы указали идентификаторы. Посмотри на эту строчку<br />TextView mInfoTextView = (TextView)findViewById(R.id.button_counter);<br />Вас ничего не смущает?</p>]]></description>
			<author><![CDATA[null@example.com (alexander.klimoff)]]></author>
			<pubDate>Wed, 17 Jan 2018 16:11:45 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=1041#p1041</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=1040#p1040</link>
			<description><![CDATA[<p>Добрый день, сделал приложение по уроку, при нажатии на &quot;поздороваться&quot; выходит Hello Kitty, а при нажатии посчитать ворон, надпись &quot;Я насчитал .. ворон&quot; прописывается в тексте кнопки, но счетчик при этом работает. Подскажите что в коде не правильно<br />package com.example.user.hello321;</p><p>import android.support.v7.app.AppCompatActivity;<br />import android.os.Bundle;<br />import android.view.View;<br />import android.widget.Button;<br />import android.widget.TextView;</p><p>public class MainActivity extends AppCompatActivity {<br />&nbsp; &nbsp; private Button mCrowsCounterButton;<br />&nbsp; &nbsp; private int mCount = 0;</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_main);<br />&nbsp; &nbsp; &nbsp; &nbsp; mCrowsCounterButton = findViewById(R.id.button_counter);<br />&nbsp; &nbsp; &nbsp; &nbsp; mCrowsCounterButton.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 mInfoTextView = (TextView)findViewById(R.id.button_counter);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mInfoTextView.setText(&quot;Я насчитал &quot; + ++mCount + &quot; ворон&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; });<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; TextView helloTextView = (TextView)findViewById(R.id.textView);<br />&nbsp; &nbsp; &nbsp; &nbsp; helloTextView.setText(&quot;Hello Kitty!&quot;);<br />&nbsp; &nbsp; }<br />}</p>]]></description>
			<author><![CDATA[null@example.com (lawyerprof)]]></author>
			<pubDate>Wed, 17 Jan 2018 13:59:46 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=1040#p1040</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=996#p996</link>
			<description><![CDATA[<p>Доброго времени суток! Я тут решил немного подправить код, чтоб лучше выглядело и возник такой вопрос: можно ли как-то покороче записать условие? Я в джаве не особо шарю, только начал учить. Вот код: </p><div class="codebox"><pre><code>package com.example.andrei.counter;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import static com.example.andrei.counter.R.id.textView_;

public class MainActivity extends Activity {

    private Button mCrowsCounterButton;
    private int mCount = 0;
    private TextView mInfoTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mCrowsCounterButton = findViewById(R.id.counterButton);
        mInfoTextView = findViewById(textView_);
        mCrowsCounterButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ++mCount;
                if (mCount % 100 == 11 | mCount % 100 == 12 | mCount % 100 == 13 | mCount % 100 == 14 | mCount % 100 == 15 | mCount % 100 == 16 | mCount % 100 == 17 | mCount % 100 == 18 | mCount % 100 == 19) {
                    mInfoTextView.setText(&quot;Я насчитал &quot; + mCount + &quot; ворон.&quot;);
                }
                else if (mCount % 10 == 1) {
                    mInfoTextView.setText(&quot;Я насчитал &quot; + mCount + &quot; ворону.&quot;);
                }
                else if (mCount % 10 == 2 | mCount % 10 == 3 | mCount % 10 == 4){
                    mInfoTextView.setText(&quot;Я насчитал &quot; + mCount + &quot; вороны.&quot;);
                }
                else{
                    mInfoTextView.setText(&quot;Я насчитал &quot; + mCount + &quot; ворон.&quot;);
                }
            }
        });
    }

    public void onClick(View view) {
        mInfoTextView.setText(&quot;Hello World!&quot;);
    }
}</code></pre></div><p>Заранее спасибо за помощь!</p>]]></description>
			<author><![CDATA[null@example.com (tuta)]]></author>
			<pubDate>Thu, 30 Nov 2017 19:49:51 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=996#p996</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=978#p978</link>
			<description><![CDATA[<div class="quotebox"><cite>NeferSky wrote:</cite><blockquote><p>Случайно, не layout назвали helloTextView?</p></blockquote></div><p>Действительно, вчера промахнулся по тексту и назвал textView фон. :)<br />Спасибо большое, что так оперативно помогли, больше постараюсь не косячить.</p>]]></description>
			<author><![CDATA[null@example.com (danila290396)]]></author>
			<pubDate>Tue, 14 Nov 2017 18:25:04 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=978#p978</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=975#p975</link>
			<description><![CDATA[<div class="quotebox"><cite>danila290396 wrote:</cite><blockquote><p>Здравствуйте, Александр!<br />Прошу прощения, если глупый вопрос.<br />У меня вылетает первое приложение, когда я нажимаю кнопку &quot;Поздороваться&quot;. В выполнении пишет:</p></blockquote></div><p>android.support.constraint.ConstraintLayout cannot be cast to android.widget.TextView<br />И вправду, cannot be.<br />Случайно, не layout назвали helloTextView?</p>]]></description>
			<author><![CDATA[null@example.com (NeferSky)]]></author>
			<pubDate>Tue, 14 Nov 2017 14:41:33 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=975#p975</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=971#p971</link>
			<description><![CDATA[<p>Приведите код разметки</p>]]></description>
			<author><![CDATA[null@example.com (alexander.klimoff)]]></author>
			<pubDate>Tue, 14 Nov 2017 07:21:20 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=971#p971</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=970#p970</link>
			<description><![CDATA[<p>Здравствуйте, Александр!<br />Прошу прощения, если глупый вопрос.<br />У меня вылетает первое приложение, когда я нажимаю кнопку &quot;Поздороваться&quot;. В выполнении пишет:</p><p>E/AndroidRuntime: FATAL EXCEPTION: main<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Process: com.example.dz.secondlesson, PID: 2633<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.lang.IllegalStateException: Could not execute method for android:onClick<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.view.View$DeclaredOnClickListener.onClick(View.java:5374)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.view.View.performClick(View.java:6294)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.view.View$PerformClick.run(View.java:24770)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Handler.handleCallback(Handler.java:790)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Handler.dispatchMessage(Handler.java:99)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Looper.loop(Looper.java:164)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.main(ActivityThread.java:6494)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Native Method)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Caused by: java.lang.reflect.InvocationTargetException<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Native Method)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.view.View$DeclaredOnClickListener.onClick(View.java:5369)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.view.View.performClick(View.java:6294) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.view.View$PerformClick.run(View.java:24770) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Handler.handleCallback(Handler.java:790) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Handler.dispatchMessage(Handler.java:99) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Looper.loop(Looper.java:164) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.main(ActivityThread.java:6494) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Native Method) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Caused by: java.lang.ClassCastException: android.support.constraint.ConstraintLayout cannot be cast to android.widget.TextView<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.example.dz.secondlesson.MainActivity.onClick(MainActivity.java:20)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Native Method) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.view.View$DeclaredOnClickListener.onClick(View.java:5369) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.view.View.performClick(View.java:6294) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.view.View$PerformClick.run(View.java:24770) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Handler.handleCallback(Handler.java:790) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Handler.dispatchMessage(Handler.java:99) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.os.Looper.loop(Looper.java:164) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at android.app.ActivityThread.main(ActivityThread.java:6494) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Native Method) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) </p><p>Не могу понять, в чем дело, я не копировал текст в onClick, писал вручную с самозаполнением. Среда немного подкорректировала код, но в целом MainActivity.java тот же:</p><p>package com.example.dz.secondlesson;</p><p>import android.annotation.SuppressLint;<br />import android.app.Activity;<br />import android.os.Bundle;<br />import android.view.View;<br />import android.widget.TextView;</p><p>public class MainActivity extends Activity {</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_main);<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; @SuppressLint(&quot;SetTextI18n&quot;)<br />&nbsp; &nbsp; public void onClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; TextView helloTextView;<br />&nbsp; &nbsp; &nbsp; &nbsp; helloTextView = findViewById(R.id.textView);<br />&nbsp; &nbsp; &nbsp; &nbsp; helloTextView.setText(&quot;hello, kitty&quot;);<br />&nbsp; &nbsp; }<br />}</p>]]></description>
			<author><![CDATA[null@example.com (danila290396)]]></author>
			<pubDate>Tue, 14 Nov 2017 00:24:42 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=970#p970</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=951#p951</link>
			<description><![CDATA[<p>Ошибся расположением, все получилось, спасибо.</p>]]></description>
			<author><![CDATA[null@example.com (deerhunter9136)]]></author>
			<pubDate>Sat, 28 Oct 2017 10:34:08 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=951#p951</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=950#p950</link>
			<description><![CDATA[<p>А вы копировали или писали вручную? Пишите ручками и испльзуйте подсказки студии. Должно получиться.</p>]]></description>
			<author><![CDATA[null@example.com (alexander.klimoff)]]></author>
			<pubDate>Sat, 28 Oct 2017 07:19:26 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=950#p950</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=949#p949</link>
			<description><![CDATA[<p>Здравствуйте, почему-то у mCrowsCounterButton нет метода setOnClickListener (горит красным), пришлось делать отдельный метод:<br />public class MainActivity extends AppCompatActivity {<br />&nbsp; &nbsp; private Button mCrowsCounterButton;<br />&nbsp; &nbsp; private int mCount = 0;<br />&nbsp; &nbsp; TextView helloTextView = findViewById(R.id.TextView);</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_main);<br />&nbsp; &nbsp; &nbsp; &nbsp; mCrowsCounterButton = findViewById(R.id.button2);<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; public void onClick(View view) {<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; helloTextView.setText(&quot;КАКИЕ КОРАБЛИ??!&quot;);<br />&nbsp; &nbsp; }</p><br /><p>&nbsp; &nbsp; public void onClick2(View view) {</p><p>&nbsp; &nbsp; &nbsp; &nbsp; helloTextView.setText(&quot;у меня получилось &quot;+ ++mCount+ &quot; ворон&quot;);<br />&nbsp; &nbsp; }<br />}</p>]]></description>
			<author><![CDATA[null@example.com (deerhunter9136)]]></author>
			<pubDate>Fri, 27 Oct 2017 21:56:20 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=949#p949</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=874#p874</link>
			<description><![CDATA[<div class="quotebox"><cite>NeferSky wrote:</cite><blockquote><p><strong>kirill_nn</strong>,<br />1. Оба счетчика у Вас увеличиваются, очевидно, потому что инкремент выполняете при присвоении текста в textView. Если я правильно Вас понял, при нажатии кнопки Вам нужно сначала увеличить счетчик, а потом присвоить текст со значениями счетчиков в textView. Сделать это можно как в приведенном примере. Обратите внимание, что инкременты ++mCountCat и ++mCount выполняется в обработчиках нажатий кнопок независимо друг от друга, а присвоение текста вынесено в отдельную функцию showCounters(), и инкремент в ней <strong>не</strong> выполняется.</p><p>2. По второму вопросу непонятно - что именно у Вас плавает?</p></blockquote></div><p>Спасибо за подсказку<br />По второму плавали кнопки, но уже разобрался</p>]]></description>
			<author><![CDATA[null@example.com (kirill_nn)]]></author>
			<pubDate>Tue, 15 Aug 2017 12:01:56 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=874#p874</guid>
		</item>
		<item>
			<title><![CDATA[Re: Щелчок кнопки/Счётчик ворон]]></title>
			<link>http://forum.alexanderklimov.ru/viewtopic.php?pid=873#p873</link>
			<description><![CDATA[<p><strong>kirill_nn</strong>,<br />1. Оба счетчика у Вас увеличиваются, очевидно, потому что инкремент выполняете при присвоении текста в textView. Если я правильно Вас понял, при нажатии кнопки Вам нужно сначала увеличить счетчик, а потом присвоить текст со значениями счетчиков в textView. Сделать это можно как в приведенном примере. Обратите внимание, что инкременты ++mCountCat и ++mCount выполняется в обработчиках нажатий кнопок независимо друг от друга, а присвоение текста вынесено в отдельную функцию showCounters(), и инкремент в ней <strong>не</strong> выполняется.</p><p>2. По второму вопросу непонятно - что именно у Вас плавает?</p><div class="codebox"><pre><code>protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mCatCounterButton = (Button) findViewById(R.id.buttonCatCounter);
        mCatCounterButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ++mCountCat;
                showCounters();
            }
        });
        mCrowCounterButton = (Button) findViewById(R.id.buttonCrowCounter);
        mCrowCounterButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ++mCount;
                showCounters();
            }
        });
    }
    public void showCounters() {
        TextView mInfoTextView = (TextView) findViewById(R.id.textView3);
        mInfoTextView .setText(&quot;Я насчитал &quot; + mCount + &quot; ворон.&quot; + &quot;И &quot; + mCountCat + &quot; котяр&quot;);
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (NeferSky)]]></author>
			<pubDate>Tue, 15 Aug 2017 10:53:20 +0000</pubDate>
			<guid>http://forum.alexanderklimov.ru/viewtopic.php?pid=873#p873</guid>
		</item>
	</channel>
</rss>
