<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094702</guid>
        <pubDate>Mon, 12 Mar 2012 14:19:02 +0000</pubDate>
        <title>Подсказки новичкам</title>
        <link>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094702</link>
        <description><![CDATA[Хрен: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352898&view=findpost&p=3094368'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Британский учёный &#064; <time class="tag-quote__quoted-time" datetime="2012-03-12T11:08:02+04:00">12.03.12, 07:08</time></span><div class='quote '>или для нотификейшенов, на которые можно забить. </div></div><br>
...или для нотификейшенов, которые юзер стопудово увидит и на которые не нужна реакция юзера. Нам нужно всего лишь проинформировать его, что поле не заполнено =)<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352898&view=findpost&p=3094368'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Британский учёный &#064; <time class="tag-quote__quoted-time" datetime="2012-03-12T07:08:02+00:00">12.03.12, 07:08</time></span><div class='quote '>саму причину того, что finish прописан не там это не пофиксает</div></div><br>
Да там он стоит, ему просто после каждого showMessage нужно return делать, потому что оно месседж показывает и сразу finish вызывает. А в onClick нужно добавить dialog.dismiss().]]></description>
        <author>Хрен</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094368</guid>
        <pubDate>Mon, 12 Mar 2012 07:08:02 +0000</pubDate>
        <title>Подсказки новичкам</title>
        <link>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094368</link>
        <description><![CDATA[Британский учёный: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352898&view=findpost&p=3094268'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Хрен &#064; <time class="tag-quote__quoted-time" datetime="2012-03-11T22:27:22+00:00">11.03.12, 22:27</time></span><div class='quote '>Это не ерунда, а вопрос дизайна и дальнейшего геморроя.</div></div><br>
Вообще то тосты обычно используют для отладки или для нотификейшенов, на которые можно забить. <br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352898&view=findpost&p=3094268'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Хрен &#064; <time class="tag-quote__quoted-time" datetime="2012-03-11T22:27:22+00:00">11.03.12, 22:27</time></span><div class='quote '>Плюс, тосты в описанном случае удобнее </div></div><br>
Я так понял что ТС просто играется с СДК и хочет разобраться что к чему. Да, тост тут спрячет багу, так как активити закроется, а тост покажется, но саму причину того, что finish прописан не там это не пофиксает :) Так что скажем твёрдое нет авнокоду на начальной стадии развития&#33;]]></description>
        <author>Британский учёный</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094268</guid>
        <pubDate>Sun, 11 Mar 2012 22:27:22 +0000</pubDate>
        <title>Подсказки новичкам</title>
        <link>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094268</link>
        <description><![CDATA[Хрен: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352898&view=findpost&p=3094264'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Британский учёный &#064; <time class="tag-quote__quoted-time" datetime="2012-03-11T22:02:42+00:00">11.03.12, 22:02</time></span><div class='quote '>Это ерунда полная.</div></div><br>
Это не ерунда, а вопрос дизайна и дальнейшего геморроя. Алерты перед закрытием контекста надо закрывать. Тосты закроются сами. Плюс, тосты в описанном случае удобнее ;)]]></description>
        <author>Хрен</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094264</guid>
        <pubDate>Sun, 11 Mar 2012 22:02:42 +0000</pubDate>
        <title>Подсказки новичкам</title>
        <link>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094264</link>
        <description><![CDATA[Британский учёный: <strong class='tag-b'>AesmaDiv</strong>, выкладывай проект, подебажу, так сходу понять сложно.<br>
<br>
Но мелкий совет:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">String title;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if(param&#62;0) title=getString(R.string.adTitleError); else title=getString(R.string.adTitleInfo);</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
Не надо этого делать. setTitle да и все остальные методы отлично скушают id ресурса.<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">setTitle(param&#62;0 ? R.string.adTitleError : R.string.adTitleInfo)</div></ol></div></div></div></div><br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352898&view=findpost&p=3094223'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Хрен &#064; <time class="tag-quote__quoted-time" datetime="2012-03-11T19:35:41+00:00">11.03.12, 19:35</time></span><div class='quote '>1. Информационные сообщения, которые гарантированно появятся только тогда, когда пользователь смотрит на экран (сразу после нажатия какой-то кнопки, к примеру) лучше делать toast&#39;ами.</div></div><br>
Это ерунда полная.<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=352898&view=findpost&p=3094223'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Хрен &#064; <time class="tag-quote__quoted-time" datetime="2012-03-11T19:35:41+00:00">11.03.12, 19:35</time></span><div class='quote '>2. Перед закрытием активити необходимо закрыть все открытые диалоги, которые были открыты в контексте данной активити. Иначе рискуешь потом словить эксепшен.</div></div><br>
Просто на онклике после обработки надо вызывать финиш. <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-11T22:10:03+00:00">11.03.12, 22:10</time></span></span><br>
<strong class='tag-b'>AesmaDiv</strong>, да, ты finish() перенеси в алерт билдер. Да и вообще структура с трай кетч как то выглядит страшновато.]]></description>
        <author>Британский учёный</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094223</guid>
        <pubDate>Sun, 11 Mar 2012 19:35:41 +0000</pubDate>
        <title>Подсказки новичкам</title>
        <link>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094223</link>
        <description><![CDATA[Хрен: 1. Информационные сообщения, которые гарантированно появятся только тогда, когда пользователь смотрит на экран (сразу после нажатия какой-то кнопки, к примеру) лучше делать toast&#39;ами.<br>2. Перед закрытием активити необходимо закрыть все открытые диалоги, которые были открыты в контексте данной активити. Иначе рискуешь потом словить эксепшен.]]></description>
        <author>Хрен</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094216</guid>
        <pubDate>Sun, 11 Mar 2012 19:14:39 +0000</pubDate>
        <title>Подсказки новичкам</title>
        <link>https://forum.sources.ru/index.php?showtopic=352898&amp;view=findpost&amp;p=3094216</link>
        <description><![CDATA[AesmaDiv: Братцы&#33; Зубры&#33; Не пинайте больно...подскажите.<br>
Ваяю свою первую аппликацию под мой новый суперфон :blush: Тема такая: при запуске стартует т.н. MainActivity. На ней помимо всякой лабудени есть кнопочка, при нажатии на которую стартует SecondActivity. На ней имеется EditText(<strong class='tag-b'>etNote</strong>) и баттон &quot;Сохранить&quot;. Вводим текст в EditText и жмём баттон...Далее код:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">public void OnClickSave(View view)throws Exception{</div><div class="code_line">&nbsp;&nbsp; &nbsp;if(etNote.length()==0){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;showMessage(getString(R.string.adMesFileEmpty),0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;if(new File(fullPath).exists()){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;showMessage(getString(R.string.adMesFileExist),0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;new File(fullPath).delete();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;try{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Writer output = new BufferedWriter(new FileWriter(fullPath));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;output.write(etNote.getText().toString());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;output.close();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}catch(Exception e){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;showMessage(getString(R.string.adMesFileError)+&quot;:\n&quot;+e, 1);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;finish();</div><div class="code_line">}</div></ol></div></div></div></div> <br>
Суть: Если поле ввода пустое выдаётся сообщение, что мол сохранять то нечего, и мы остаёмся на этой activity. Если поле не пустое проверяется есть ли уже файл с таким именем (тут всё хоккей) и если таки есть - выводится соответствующее сообщение, файлик стирается и создается новый. После чего activity закрывается и мы возвращаемся на MainActivity.<br>
Проблема в следующем: вывод сообщения реализуется при помощи AlertDialog с PositiveButton. И по идее перед завершением activity надо бы дождаться нажатия на эту самую PositiveButton, ан нет. Сообщение только мелькнет и activity сворачивается. Или я не в ту сторону дую?<br>
<br>
зы. Код <strong class='tag-b'>showMessage</strong><br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">public void showMessage(String message, int param){</div><div class="code_line">&nbsp;&nbsp; &nbsp;String title;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if(param&#62;0) title=getString(R.string.adTitleError); else title=getString(R.string.adTitleInfo);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;new AlertDialog.Builder(this)</div><div class="code_line">&nbsp;&nbsp; &nbsp;.setTitle(title)</div><div class="code_line">&nbsp;&nbsp; &nbsp;.setMessage(message)</div><div class="code_line">&nbsp;&nbsp; &nbsp;.setPositiveButton(getString(R.string.adButtonPos),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;new DialogInterface.OnClickListener() {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public void onClick(DialogInterface dialog, int which) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;})</div><div class="code_line">&nbsp;&nbsp; &nbsp;.show();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div></ol></div></div></div></div>]]></description>
        <author>AesmaDiv</author>
        <category>Android</category>
      </item>
	
      </channel>
      </rss>
	