<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule" >
  <channel>
  <title>からすまる日誌 java</title>
  <link>https://apikarasumaru.ko-me.com/</link>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="https://apikarasumaru.ko-me.com/RSS/" />
  <description>授業ノートのまとめ</description>
  <lastBuildDate>Tue, 23 Feb 2021 05:50:34 GMT</lastBuildDate>
  <language>ja</language>
  <copyright>© Ninja Tools Inc.</copyright>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />

    <item>
    <title>android studio(11)  sound</title>
    <description>
    <![CDATA[<div>サウンド<br />
&nbsp;</div>
<div>ばーんと配布プリント1-4のコードを</div>
<div>貼る<br />
http://m.gmobb.jp/ymmkito/doujyo/android/SoundActivity.java</div>
<div>&nbsp;</div>
<div>resの中にディレクトリ新規作成したい：</div>
<div><span style="color: #ff0000;">resのうえで右クリック</span>&rarr;新規ディレクトリ　raw</div>
<div>そこにDLした音源を入れる</div>
<div>C:\Users\web.DESKTOP-EQR2U6K\Desktop\android_stadio\Lesson4\app\src\main\res\raw<br />
&nbsp;<br />
この方法以外でやってしまったら変なとこにできてハテナになってしまった。</div>
<div></div>
<div>　</div>
<div>soundに関しては</div>
<div>いま流れてるものをstopして</div>
<div>プリペアして</div>
<div>startしないと動かない(stop&rarr;startだけではだめ)</div>
<div>　　</div>
<div>finishが入っていたり入っていなかったりする件：</div>
<div>mainがあってtimeがあって、またmainに戻ってをすると、3画面開いているらしい</div>
<div>startするとどんどんふ増える</div>
<div>そんなに増やすのいやだなというときはfinishをつかう</div>
<div>そうするとじぶんがおわる(ウィンドウが閉じる)</div>
<div>　</div>
<div>androidstadioは、いまxmlでかくのが主流。</div>
<div>昔気質の筆者はjavaばかりで説明するらしい<br />
本を買う時はどっちのスタイルかみてから買うといい(両方が理想)</div>
<div>　</div>
<div>マシンは8GBのメモリでもいける。SSDがよろしい。</div>
<div>　</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030552.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583391561/" /></a> <br />
　</div>
<div>&uarr;このGradleスクリプトのあたりはまあ触ることがない。ごくごくまれに「このバージョンでは動かないやん｣というとき<br />
ここを29.0.0にしたら動くとかいうことがあるらしい。</div>
<div>　</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030553.png" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583391575/" /></a> <br />
　</div>
<div>Constraint Layout　コンストレイントレイアウト（こんすとらくと？レイアウト）レイアウトにボタン１つでするにはこれ。</div>
<div>こっちにしておいたほうがアンドロイドさん的に画面が速い</div>
<div>ので、</div>
<div>リニアレイアウトでつくっておいて、できあがったら最後に変換するのがよい。</div>
<div>　</div>
<div><hr /></div>
<div>soundActivityもうごいてよかった</div>
<div>なおシステムUIは動いていません的なエラーが出たが、単純にしばらく待ってやり直したら普通に動いたりした</div>
<div>　</div>
<div><strong>SoundActivity.java<br />
　</strong></div>
<div>&nbsp;package com.example.lesson4;</div>
<div></div>
<div>import androidx.annotation.RequiresApi;</div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div></div>
<div>import android.content.Intent;</div>
<div>import android.media.AudioAttributes;</div>
<div>import android.media.AudioManager;</div>
<div>import android.media.MediaPlayer;</div>
<div>import android.media.SoundPool;</div>
<div>import android.os.Build;</div>
<div>import android.os.Bundle;</div>
<div>import android.view.View;</div>
<div>import android.widget.Button;</div>
<div></div>
<div>public class SoundActivity extends AppCompatActivity&nbsp; implements View.OnClickListener {</div>
<div></div>
<div>&nbsp; &nbsp; private Button mainButton, soundButton1, soundButton2;</div>
<div>&nbsp; &nbsp; private SoundPool soundPool;</div>
<div>&nbsp; &nbsp; private int soundId;</div>
<div>&nbsp; &nbsp; private MediaPlayer mediaPlayer;</div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_sound);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundButton1 = findViewById(R.id.soundButton1);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundButton2 = findViewById(R.id.soundButton2);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; mainButton = findViewById(R.id.mainButton);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundButton1.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundButton2.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; mainButton.setOnClickListener(this);</div>
<div></div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)</div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onResume() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onResume();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; AudioAttributes attr = new AudioAttributes.Builder()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setUsage(AudioAttributes.USAGE_MEDIA)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //AudioAttributes.USAGE_GAME</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .build();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundPool = new SoundPool.Builder()</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setAudioAttributes(attr)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setMaxStreams(4)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .build();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundId = soundPool.load(this, R.raw.se, 1);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; mediaPlayer = MediaPlayer.create(this, R.raw.se);</div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onPause() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onPause();</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundPool.release();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; mediaPlayer.release();</div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Intent intent;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (v != null) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (v.getId()) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case R.id.soundButton1:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soundPool.play(soundId, 100, 100, 1, 0, 1);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case R.id.soundButton2:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (mediaPlayer.isPlaying()) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mediaPlayer.<span style="color: #ff0000;">stop</span>();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mediaPlayer.<span style="color: #ff0000;">prepare</span>();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mediaPlayer.seekTo(0);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mediaPlayer.<span style="color: #ff0000;">start</span>();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case R.id.mainButton:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finish();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div><br />
&nbsp;</div>
<div>}&nbsp;</div>
<div>&nbsp;</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030554.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583391600/" /></a></div>
<div><hr /></div>
<div>Mainはこう</div>
<div>　</div>
<div><strong>MainActivity.java</strong></div>
<div>&nbsp;</div>
<div>package com.example.lesson4;</div>
<div></div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div></div>
<div>import android.content.Intent;</div>
<div>import android.os.Bundle;</div>
<div>import android.preference.PreferenceActivity;</div>
<div>import android.view.View;</div>
<div>import android.widget.Button;</div>
<div>import android.widget.EditText;</div>
<div>import android.widget.TextView;</div>
<div></div>
<div>public class MainActivity extends AppCompatActivity implements View.OnClickListener{</div>
<div>&nbsp; &nbsp; private TextView myText;</div>
<div>&nbsp; &nbsp; private Button timeButton,preferenceButton,soundButton;</div>
<div>&nbsp; &nbsp; private EditText myEdit;</div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_main);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myEdit = findViewById(R.id.myEdit);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; timeButton = findViewById(R.id.timeButton);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; preferenceButton = findViewById(R.id.preferenceButton);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundButton = findViewById(R.id.soundButton);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; timeButton.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; preferenceButton.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundButton.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Intent intent;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (v != null) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (v.getId()) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;"> case R.id.timeButton:</span></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; intent = new Intent(this, TimeActivity.class);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startActivity(intent);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;"> case R.id.preferenceButton:</span></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; intent = new Intent(this, MyPreferenceActivity.class);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; intent.putExtra("<span style="color: #ff9900;">iData</span>", myEdit.getText().toString());</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startActivity(intent);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;"> case R.id.soundButton:</span></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; intent = new Intent(this, SoundActivity.class);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startActivity(intent);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div>&nbsp;</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030555.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583391617/" />　<br />
</a></div>
<div><br />
lesson4はzipして自分のドライブに投げてある</div>
<div>&nbsp;</div>]]>
    </description>
    <category>android studio</category>
    <link>https://apikarasumaru.ko-me.com/android%20studio/android%20studio-11-%20%20sound</link>
    <pubDate>Fri, 05 Mar 2021 00:55:31 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/106</guid>
  </item>
    <item>
    <title>android studio(10) 画面遷移</title>
    <description>
    <![CDATA[<div>Lesson4</div>
<div>エミュレーターのsetting</div>
<div>&nbsp;<br />
このへんを上にドラッグ。</div>
<div><a title="" href="//karasumaru.ko-me.com/File/20200305400.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583384502/" /></a> <br />
　</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030540.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583384513/" /></a></div>
<div></div>
<div>言語設定</div>
<div>設定&rarr;システム&rarr;言語&rarr;日本語を選んで一番上にセット</div>
<div>設定&rarr;システム&rarr;日付と時刻</div>
<div>　</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030541.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583384524/" /></a> <br />
　</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030542.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583384536/" /></a></div>
<div>　</div>
<div><hr /><hr /></div>
<div>時間処理　時間の計算</div>
<div>　</div>
<div>datepickerがjsにもあれば制作課題にも使えるな</div>
<div>　</div>
<div><hr /><hr /></div>
<div><strong>画面遷移　</strong></div>
<div>　</div>
<div>マニフェスト</div>
<div>&lt;activity android:name=".TimeActivity"&gt;&lt;/activity&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;activity android:name=".MainActivity"&gt;</div>
<div>にもどしておく</div>
<div>　</div>
<div>activity_main</div>
<div></div>
<div><span style="color: #ff0000;">plene text</span>を選ぶとedit textができる</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030543.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583384556/" /></a></div>
<div>　</div>
<div><hr /></div>
<div>遷移するやつ</div>
<div>&nbsp;</div>
<div>MainActivity.java</div>
<div>&nbsp;</div>
<div>package com.example.lesson4;</div>
<div><br />
&nbsp;</div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div></div>
<div>import android.content.Intent;</div>
<div>import android.os.Bundle;</div>
<div>import android.view.View;</div>
<div>import android.widget.Button;</div>
<div>import android.widget.EditText;</div>
<div>import android.widget.TextView;</div>
<div>&nbsp;</div>
<div>public class MainActivity extends AppCompatActivity implements View.OnClickListener{</div>
<div>&nbsp; &nbsp; private TextView myText;</div>
<div>&nbsp; &nbsp; private Button timeButton,preferenceButton,soundButton;</div>
<div>&nbsp; &nbsp; private EditText myEdit;</div>
<div><br />
&nbsp;</div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_main);</div>
<div>&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myEdit = findViewById(R.id.myEdit);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; timeButton = findViewById(R.id.timeButton);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; preferenceButton = findViewById(R.id.preferenceButton);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundButton = findViewById(R.id.soundButton);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; timeButton.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; preferenceButton.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; soundButton.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; Intent intent;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (v != null) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (v.getId()) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case R.id.timeButton:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; intent = new Intent(this, TimeActivity.class);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startActivity(intent);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div>&nbsp;</div>
<div><hr /></div>
<div>マニフェストに</div>
<div>activityの宣言文がないと</div>
<div>おちるよ</div>
<div>　</div>
<div><hr /><hr /></div>
<div>ぷりふぁれんす</div>
<div>データの保存</div>
<div></div>
<div>新規</div>
<div>アクティビティ</div>
<div>空のアクティビティ</div>
<div>　</div>
<div>でつくらないと、必要なセットが生成されないよ</div>
<div>　</div>]]>
    </description>
    <category>android studio</category>
    <link>https://apikarasumaru.ko-me.com/android%20studio/android%20studio-10-%20%E7%94%BB%E9%9D%A2%E9%81%B7%E7%A7%BB</link>
    <pubDate>Fri, 05 Mar 2021 00:54:11 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/105</guid>
  </item>
    <item>
    <title>android studio(9) 時間表示</title>
    <description>
    <![CDATA[<div>プリント<br />
4つめのパターンでやる</div>
<div>&nbsp;</div>
<div>４．onClick プロパティで指定したメソッドを作る</div>
<div>　</div>
<div>package com.example.lesson4;</div>
<div></div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div></div>
<div>import android.os.Bundle;</div>
<div>import android.view.View;</div>
<div>import android.widget.Button;</div>
<div>import android.widget.TextView;</div>
<div></div>
<div>public class MainActivity extends AppCompatActivity{</div>
<div>&nbsp; &nbsp; private TextView myText;</div>
<div>&nbsp; &nbsp; private Button myButton1;</div>
<div>&nbsp; &nbsp; private Button myButton2;</div>
<div>&nbsp; &nbsp; private Button myButton3;</div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_main);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myText = findViewById(R.id.myText);/*newする必要はなくひもづけだけする*/</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton1 = findViewById(R.id.button);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton2 = findViewById(R.id.button2);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton3 = findViewById(R.id.button3);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; /*</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton1.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton2.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; */</div>
<div></div>
<div></div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; public void myClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myText.setText("aaaaaaa");</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; /*</div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (v != null) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (v.getId()) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case R.id.button:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //処理</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("bye wolrd");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case R.id.button2:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //処理</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("hello wolrd");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp;*/</div>
<div>}</div>
<div>　</div>
<div><hr /><hr /></div>
<div>時間処理</div>
<div>　</div>
<div>.javaを選んでる状態で</div>
<div>ファイル</div>
<div>&rarr;新規</div>
<div>&rarr;新規アクティビティ<br />
&nbsp;</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030520.png" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380574/" /></a></div>
<div>　</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030521.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380586/" />&nbsp;<br />
</a></div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030522.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380599/" /></a></div>
<div>&nbsp;<br />
<a title="" href="//karasumaru.ko-me.com/File/2020030523.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380615/" /></a></div>
<div>　</div>
<div>&gt;II. 時間処理</div>
<div>１）アクティビティの追加</div>
<div>ファイル &rarr; 新規 &rarr; アクティビティ &rarr; 空のアクティビティ</div>
<div>Activity 名：TimeActivity</div>
<div>レイアウト：activity_time(規定のまま)</div>
<div>※確認</div>
<div>・作成されたクラスファイル、レイアウトファイル</div>
<div>・マニフェスト内容</div>
<div>２）起動アクティビティを TimeActivity に変更</div>
<div>　</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030524.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380630/" /></a></div>
<div></div>
<div>３）レイアウトの変更、コントロールの追加</div>
<div>① LinearLayout に変更</div>
<div>② コントロールの追加</div>
<div>種類 id 変数名</div>
<div>TextView nowText nowText</div>
<div>４）TimeActivity の作成</div>
<div>TextView に現在時刻を表示するようにします。</div>
<div>&nbsp;</div>
<div>あかいところは<span style="color: #ff0000;">alt+enter</span>してインポートする</div>
<div>候補のどれをインポートするかわかるには経験がいる</div>
<div>　</div>
<div><strong>TimeActivity.java</strong></div>
<div></div>
<div>package com.example.lesson4;</div>
<div></div>
<div>import android.os.Bundle;</div>
<div>import android.os.Handler;</div>
<div>import android.view.View;</div>
<div>import android.widget.TextView;</div>
<div></div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div></div>
<div>import java.text.SimpleDateFormat;</div>
<div>import java.util.Calendar;</div>
<div>import java.util.Date;</div>
<div>import java.util.Timer;</div>
<div>import java.util.TimerTask;</div>
<div></div>
<div>public class TimeActivity extends AppCompatActivity implements View.OnClickListener {</div>
<div>&nbsp; &nbsp; // 時刻表示のフォーマット定義</div>
<div>&nbsp; &nbsp; private static SimpleDateFormat formatDateTime = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");</div>
<div>&nbsp; &nbsp; private static SimpleDateFormat formatDate = new SimpleDateFormat("yyyy/MM/dd");</div>
<div>&nbsp; &nbsp; private Handler myHandler;</div>
<div>&nbsp; &nbsp; private Timer myTimer;</div>
<div>&nbsp; &nbsp; private Date today;</div>
<div>&nbsp; &nbsp; private TextView nowText;</div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_time);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myHandler = new Handler(getMainLooper());</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myTimer = new Timer();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myTimer.schedule(new TimerTask() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void run() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myHandler.post(new Runnable() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void run() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Calendar calendar = Calendar.getInstance();</div>
<div>// 時刻表示</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ((TextView) findViewById(R.id.nowText)).setText(formatDateTime.format(calendar.getTime()));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }, 0, 1000);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; nowText = findViewById(R.id.nowText);</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onDestroy() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onDestroy();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (myTimer != null) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myTimer.cancel();</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myTimer = null;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (v != null) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (v.getId()) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div>　</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030525.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380647/" /></a></div>
<div>　</div>
<div></div>
<div>これはマルチスレッドのプログラム</div>
<div>&nbsp;</div>
<div>timeactivity(たいむあくてぃびてぃ)と</div>
<div>mytimer(まいたいまー)の</div>
<div>2つが動いている</div>
<div>　　</div>
<div><hr /></div>
<div>1000ミリ秒ごとにフォーマット整えて表示している</div>
<div></div>
<div>メインアクティビティは、ふつうメインアクティビティを閉じたときにおなくなりになるけど</div>
<div>このプログラムでは必要があってここで手動でおなくなりにしている<br />
&nbsp;</div>
<div>&nbsp; &nbsp; <span style="color: #ff0000;">protected void onDestroy() {</span></div>
<div><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; super.onDestroy();</span></div>
<div><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; if (myTimer != null) {</span></div>
<div><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myTimer.cancel();</span></div>
<div><span style="color: #ff0000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myTimer = null;</span></div>
<div>　</div>
<div>ルールとして</div>
<div>サブのスレッドから</div>
<div>メインのコントロールには直接触れないというルールがある</div>
<div>なのでpostという依頼をする</div>
<div>　</div>
<div>サブからメインのコントロール</div>
<div>&nbsp;</div>
<div>メインスレッド：テキストボックスを表示</div>
<div>サブ：やりたい処理を投函しておく（post）</div>
<div>メインのタイミングのいいときに更新する</div>
<div>&nbsp;　</div>
<div>このあたりの部分のおはなしらしい<br />
&nbsp;</div>
<div>myTimer.schedule(new TimerTask() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void run() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myHandler.<span style="color: #ff0000;">post</span>(new Runnable() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void run() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Calendar calendar = Calendar.getInstance();</div>
<div>// 時刻表示</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ((TextView) findViewById(R.id.nowText)).setText(formatDateTime.format(calendar.getTime()));</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>　</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030526.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380663/" /></a> <br />
&nbsp;</div>
<div><hr /></div>
<div>このpostがないと（ダイレクトにやると）起動してもすぐおちて、あんたのところからメインのところにはさわれませんよとエラーがでる</div>
<div>サブからポストして、メインさんの都合のいいタイミングで実行していただくというかたち</div>
<div>　</div>
<div><hr /></div>
<div>あと何日プログラムに修正しますよ<br />
&nbsp;</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030527.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380685/" /></a> <br />
&nbsp;</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030528.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380699/" /></a> <br />
&nbsp;</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030529.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380711/" /></a> <br />
&nbsp;<br />
<a title="" href="//karasumaru.ko-me.com/File/2020030530.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380722/" /></a> <br />
&nbsp;</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030531.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583380735/" /></a> <br />
&nbsp;</div>
<div></div>]]>
    </description>
    <category>android studio</category>
    <link>https://apikarasumaru.ko-me.com/android%20studio/android%20studio-9-%20%E6%99%82%E9%96%93%E8%A1%A8%E7%A4%BA</link>
    <pubDate>Fri, 05 Mar 2021 00:52:29 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/104</guid>
  </item>
    <item>
    <title>android studio(8) プリファレンス(前の画面の情報の受け渡し)</title>
    <description>
    <![CDATA[<div>あさの　おはなし<br />
　<br />
電卓<br />
M+ メモリに計算結果を格納</div>
<div>MR メモリーリコール　メモリした数を呼び出す</div>
<div>MC　メモリクリア</div>
<div>C　全消し</div>
<div>CE　直前のエントリーを消す</div>
<div>　</div>
<div><hr /></div>
<div>プリファレンス　前の情報の取り方</div>
<div>　</div>
<div>今日はプリントで</div>
<div>Android stadio</div>
<div>&nbsp;</div>
<div>新規プロジェクト</div>
<div>&rarr;空のアクティビティ<br />
&nbsp;</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030502.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583375403/" /></a></div>
<div>　</div>
<div>レイアウトエディターでもやる</div>
<div>長いコードはコピペで</div>
<div>　</div>
<div>おさらい</div>
<div>appに入っている<br />
マニフェストでみると.MainActivityに設定されてる</div>
<div>　</div>
<div>リニアレイアウトに変更<br />
&nbsp;</div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030503.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583375421/" /></a> <br />
&nbsp;<br />
<a title="" href="//karasumaru.ko-me.com/File/2020030504.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583375439/" /></a></div>
<div>　</div>
<div>コントロールを追加していく</div>
<div>　</div>
<div></div>
<div><a title="" href="//karasumaru.ko-me.com/File/2020030508.PNG" target="_blank"><img alt="" src="//karasumaru.ko-me.com/Img/1583375453/" /></a></div>
<div>　</div>
<div>http://m.gmobb.jp/ymmkito/doujyo/android/Android0111.pdf</div>
<div>ここからこぴってよい<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020030510.png" title=""><img src="//karasumaru.ko-me.com/Img/1583454185/" alt="" /></a> <br />
　</div>
<div>myText.</div>
<div>まで入力するとオブジェクトにどうしたいかのメソッド候補が現れる</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020030511.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1583454202/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020030513.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1583454220/" alt="" /></a> <br />
　</div>
<div>ボタンを追加したら</div>
<div>2つ追加する<br />
&nbsp;</div>
<div>private Button myButton2;</div>
<div>と</div>
<div>myButton2 = findViewById(R.id.button2);</div>
<div>と</div>
<div>&nbsp;myButton2.setOnClickListener(new View.OnClickListener() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("Hello wolrd!");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp;});</div>
<div>　</div>
<div>3つだった。</div>
<div>　</div>
<div><hr /></div>
<div>クラスのなかでつくるクラス</div>
<div>インナークラスとか無名クラスとかいう。</div>
<div>いまやったのがそのやり方</div>
<div>　</div>
<div>いろんなやりかたがあるらしく、サンプルによって違うので混乱することがあるらしい</div>
<div>　</div>
<div>イベントリスナーの実装のやり方<br />
　</div>
<div>方法１．インナークラス（無名クラス、匿名クラス）を作る</div>
<div>２．Activity にリスナーインターフェースを実装させ る(implements)</div>
<div>３．クラスを作る</div>
<div>４．onClick プロパティで指定したメソッドを作る</div>
<div>&nbsp;</div>
<div>ボタンが3つ4つ並んでいるとonCreateメソッドのなかがごちゃごちゃする&rarr;2.が多くなる</div>
<div>　</div>
<div><hr />インプリメンツ</div>
<div>クリックリスナーというのは</div>
<div>かならずオンクリックメソッドを実行させないといけないというやつ</div>
<div>抽象メソッドとして実装し実行時に決めてくださいというあれ。</div>
<div>　</div>
<div>２．Activity にリスナーインターフェースを実装させる(implements)<br />
　</div>
<div>public class Sample extends AppCompatActivity <span style="color: #ff0000;">implements</span> View.OnClickListener {<br />
　</div>
<div>&nbsp;@Override</div>
<div>&nbsp;protected void onCreate(Bundle savedInstanceState) {</div>
<div>　～中略～</div>
<div>&nbsp;　button.setOnClickListener(this);</div>
<div>&nbsp;}<br />
　</div>
<div>@Override</div>
<div>public void onClick(View v) {</div>
<div>&nbsp;if (v != null) {</div>
<div>&nbsp;　switch (v.getId()) {</div>
<div>&nbsp;　case R.id.button:</div>
<div>　　//処理</div>
<div>　 break;</div>
<div>　 default:</div>
<div>&nbsp;　break;</div>
<div>　 }</div>
<div>}</div>
<div>}</div>
<div>}</div>
<div>　</div>
<div>vのところに入れるらしい　</div>
<div>　</div>
<div><hr /></div>
<div>2.のやりかたに今のコードを変更するよ</div>
<div>&nbsp;　</div>
<div>いまのコード：<br />
&nbsp;</div>
<div>package com.example.lesson4;</div>
<div></div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div></div>
<div>import android.os.Bundle;</div>
<div>import android.view.View;</div>
<div>import android.widget.Button;</div>
<div>import android.widget.TextView;</div>
<div></div>
<div>public class MainActivity extends AppCompatActivity {</div>
<div>&nbsp; &nbsp; private TextView myText;</div>
<div>&nbsp; &nbsp; private Button myButton1;</div>
<div>&nbsp; &nbsp; private Button myButton2;</div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_main);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myText = findViewById(R.id.myText);<span style="color: #99cc00;">/*newする必要はなくひもづけだけする*/</span></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton1 = findViewById(R.id.button);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton2 = findViewById(R.id.button2);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton1.<span style="color: #ff0000;">setOnClickListener</span>(new View.OnClickListener() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #99cc00;"> //myText に「Bye World!」と表示する Let's do it!</span></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("bye wolrd!");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; });</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton2.<span style="color: #ff0000;">setOnClickListener</span>(new View.OnClickListener() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("Hello wolrd!");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; });</div>
<div></div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div><br />
&nbsp;</div>
<div>&darr;</div>
<div>　</div>
<div><strong>MainActivity.java</strong></div>
<div>&nbsp;</div>
<div>package com.example.lesson4;</div>
<div></div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div></div>
<div>import android.os.Bundle;</div>
<div>import android.view.View;</div>
<div>import android.widget.Button;</div>
<div>import android.widget.TextView;</div>
<div></div>
<div>public class MainActivity extends AppCompatActivity implements View.OnClickListener {</div>
<div>&nbsp; &nbsp; private TextView myText;</div>
<div>&nbsp; &nbsp; private Button myButton1;</div>
<div>&nbsp; &nbsp; private Button myButton2;</div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_main);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myText = findViewById(R.id.myText);/*newする必要はなくひもづけだけする*/</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton1 = findViewById(R.id.button);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton2 = findViewById(R.id.button2);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton1.setOnClickListener(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myButton2.setOnClickListener(this);</div>
<div></div>
<div><span style="color: #999999;">&nbsp; &nbsp; &nbsp; &nbsp; /*リスナーインターフェイスのやり方*/</span></div>
<div><span style="color: #999999;">&nbsp; &nbsp; &nbsp; &nbsp; //@Override</span></div>
<div><span style="color: #999999;">&nbsp; &nbsp; &nbsp; &nbsp; //public void onClick(View v) {</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (v != null) {</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (v.getId()) {</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case R.id.button:</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //処理</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("bye wolrd");</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case R.id.button2:</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //処理</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("hello wolrd");</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</span></div>
<div><span style="color: #999999;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div>
<div><span style="color: #999999;">&nbsp; &nbsp; &nbsp; &nbsp; //}</span></div>
<div><span style="color: #999999;">&nbsp; &nbsp; &nbsp; &nbsp; // }</span></div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (v != null) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (v.getId()) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">case R.id.button:</span></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //処理</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("bye wolrd");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">case R.id.button2:</span></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //処理</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("hello wolrd");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div></div>
<div>&nbsp;</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020030514.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1583454386/" alt="" /></a> <br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020030515.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1583454402/" alt="" /></a> <br />
　<br />
このブロックでくくるのを意識する。<br />
今回｝がずれていたのでエラーが出ていた。<br />
　</div>
<div></div>
<div></div>]]>
    </description>
    <category>android studio</category>
    <link>https://apikarasumaru.ko-me.com/android%20studio/android%20studio-8-%20%E3%83%97%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9-</link>
    <pubDate>Fri, 05 Mar 2021 00:49:07 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/103</guid>
  </item>
    <item>
    <title>実践2(15) 自作計算機その3</title>
    <description>
    <![CDATA[まだ問題がある<br />
・＝を押した後pushEqual=trueなのにif文のなかのボタンが有効な問題<br />
・数字ボタンの処理がまぬすぎる　forで？<br />
　<br />
<hr /><br />

<div>package application;</div>
<div></div>
<div>import javafx. application.Application;</div>
<div>import javafx.event.ActionEvent;</div>
<div>import javafx. scene.Scene;</div>
<div>import javafx.scene.control.TextField;</div>
<div>import javafx.scene.control.ToggleButton;</div>
<div>import javafx.scene.control.ToggleGroup;</div>
<div>import javafx.scene.layout.HBox;</div>
<div>import javafx.scene.layout.TilePane;</div>
<div>import javafx.scene.layout.VBox;</div>
<div>import javafx.scene.text.Font;</div>
<div>import javafx. stage.Stage;</div>
<div></div>
<div>public class Calculator_from_EXE3115 extends Application {</div>
<div></div>
<div><span style="white-space: pre;"> </span>int kigou =0;//何の記号がおされたか。1は＋,2は-,3は*,4は/</div>
<div><span style="white-space: pre;"> </span>double hogenum;//数字を格納</div>
<div><span style="white-space: pre;"> </span>String hogestr;//入力中の数字文字を格納</div>
<div><span style="white-space: pre;"> </span>boolean pushEqual;//=キーが押されたかどうか</div>
<div><span style="white-space: pre;"> </span>boolean pushDot = false;//小数点がおされたかどうか</div>
<div></div>
<div></div>
<div><span style="white-space: pre;"> </span>public static void main(String[] args) {</div>
<div><span style="white-space: pre;"> </span>launch(args);</div>
<div><span style="white-space: pre;"> </span>}</div>
<div></div>
<div><span style="white-space: pre;"> </span>@Override</div>
<div><span style="white-space: pre;"> </span>public void start(Stage myStage) {</div>
<div></div>
<div><span style="white-space: pre;"> </span>TextField tf1 = new TextField("");</div>
<div></div>
<div><span style="white-space: pre;"> </span>//ここはひらさわさんのをこぴった</div>
<div><span style="white-space: pre;"> </span>//数字キーボタンを配列に入れる</div>
<div><span style="white-space: pre;"> </span>ToggleGroup group1 = new ToggleGroup();</div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>ToggleButton[] tbNum = new ToggleButton[10];</div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>for(int i=0; i&lt;10; i++) {</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>//tbNum[i] = new ToggleButton("\t" + i + "\t");</div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbNum[i] = new ToggleButton(i+"");</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbNum[i].setToggleGroup(group1);</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbNum[i].setUserData(i);<span style="white-space: pre;"> </span>// データをセット</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbNum[i].setFont( Font.font("meiryo",15) );</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbNum[i].setPrefWidth(100);</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbNum[i].setPrefHeight(50);</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>if(i%2==0) {</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbNum[i].setStyle("-fx-background-color:red; -fx-text-fill:black; -fx-border-color:#555;");</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>}else {</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbNum[i].setStyle("-fx-background-color:white; -fx-text-fill:black; -fx-border-color:#555;");</div>
<div></div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>}</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>//記号</div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>String[] calcArray = {"","=", "AC", "+", "-", "*", "/", "."};</div>
<div></div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>ToggleGroup group2 = new ToggleGroup();</div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>ToggleButton[] tbOpe = new ToggleButton[calcArray.length];</div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>for(int i=0; i&lt;calcArray.length; i++) {</div>
<div><span style="white-space: pre;"> </span>//tbOpe[i] = new ToggleButton("\t" + calcArray[i] + "\t");</div>
<div><span style="white-space: pre;"> </span>tbOpe[i] = new ToggleButton(calcArray[i]+"");</div>
<div><span style="white-space: pre;"> </span>tbOpe[i].setToggleGroup(group2);</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbOpe[i].setUserData(calcArray[i]);<span style="white-space: pre;"> </span>// データをセット</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbOpe[i].setFont( Font.font("meiryo",15) );</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbOpe[i].setPrefWidth(100);</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbOpe[i].setPrefHeight(50);</div>
<div><span style="white-space: pre;"> </span>&nbsp; &nbsp; <span style="white-space: pre;"> </span>tbOpe[i].setStyle("-fx-background-color:#4287f5; -fx-text-fill:black; -fx-border-color:#555;");</div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>}</div>
<div></div>
<div><span style="white-space: pre;"> </span>//------------</div>
<div><span style="white-space: pre;"> </span>//pane</div>
<div><span style="white-space: pre;"> </span>//------------</div>
<div></div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>HBox pane2 = new HBox();</div>
<div><span style="white-space: pre;"> </span>pane2.getChildren().addAll(tf1);</div>
<div></div>
<div>&nbsp; &nbsp; <span style="white-space: pre;"> </span>HBox pane3 = new HBox();</div>
<div><span style="white-space: pre;"> </span>pane3.getChildren().addAll(tbOpe[2]);//ACボタン</div>
<div></div>
<div><span style="white-space: pre;"> </span>TilePane pane5 = new TilePane();</div>
<div><span style="white-space: pre;"> </span>pane5.getChildren().addAll(tbNum[7],tbNum[8],tbNum[9],tbOpe[6],tbNum[4],tbNum[5],tbNum[6],tbOpe[5],tbNum[1],tbNum[2],tbNum[3],tbOpe[4],tbNum[0],tbOpe[7],tbOpe[1],tbOpe[3]);</div>
<div></div>
<div><span style="white-space: pre;"> </span>VBox pane = new VBox();</div>
<div><span style="white-space: pre;"> </span>pane.getChildren().addAll(pane2,pane3,pane5);</div>
<div><span style="white-space: pre;"> </span>pane.setStyle("-fx-background-color:#deebff;");</div>
<div></div>
<div><span style="white-space: pre;"> </span>//------------</div>
<div><span style="white-space: pre;"> </span>//各種ボタン</div>
<div><span style="white-space: pre;"> </span>//------------</div>
<div></div>
<div><span style="white-space: pre;"> </span>//数字</div>
<div><span style="white-space: pre;"> </span>if(pushEqual==false) {</div>
<div></div>
<div><span style="white-space: pre;"> </span>tbNum[0].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"0");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>tbNum[1].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>System.out.println("pushEqual is "+pushEqual);</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"1");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>tbNum[2].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"2");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>tbNum[3].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"3");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>tbNum[4].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"4");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>tbNum[5].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"5");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>tbNum[6].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"6");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div></div>
<div><span style="white-space: pre;"> </span>tbNum[7].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"7");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>tbNum[8].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"8");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>tbNum[9].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+"9");</div>
<div><span style="white-space: pre;"> </span>});</div>
<div></div>
<div><span style="white-space: pre;"> </span>//小数点</div>
<div><span style="white-space: pre;"> </span>tbOpe[7].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>if(pushDot==false) {//小数点は2回押せないように</div>
<div><span style="white-space: pre;"> </span>hogestr =tf1.getText();</div>
<div><span style="white-space: pre;"> </span>tf1.setText(hogestr+".");</div>
<div><span style="white-space: pre;"> </span>pushDot=true;</div>
<div><span style="white-space: pre;"> </span>System.out.println("pushDotはいま"+pushDot);</div>
<div><span style="white-space: pre;"> </span>}</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>}else {</div>
<div></div>
<div><span style="white-space: pre;"> </span>System.out.println("pushEqualにつきfalse");</div>
<div><span style="white-space: pre;"> </span>}</div>
<div></div>
<div></div>
<div><span style="white-space: pre;"> </span>//＝ボタン</div>
<div><span style="white-space: pre;"> </span>tbOpe[1].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogenum =calc(tf1.getText(),kigou);</div>
<div><span style="white-space: pre;"> </span>tf1.setText("計算結果は"+hogenum);</div>
<div><span style="white-space: pre;"> </span>pushEqual=true;</div>
<div><span style="white-space: pre;"> </span>System.out.println("pushEqualはいま"+pushEqual);</div>
<div><span style="white-space: pre;"> </span>});</div>
<div></div>
<div><span style="white-space: pre;"> </span>//＋ボタン</div>
<div><span style="white-space: pre;"> </span>tbOpe[3].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogenum =calc(tf1.getText(),kigou);</div>
<div><span style="white-space: pre;"> </span>tf1.setText("");</div>
<div><span style="white-space: pre;"> </span>kigou=1;//最後に押された記号は足す</div>
<div><span style="white-space: pre;"> </span>});</div>
<div></div>
<div><span style="white-space: pre;"> </span>//-ボタン</div>
<div><span style="white-space: pre;"> </span>tbOpe[4].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogenum =calc(tf1.getText(),kigou);</div>
<div><span style="white-space: pre;"> </span>tf1.setText("");</div>
<div><span style="white-space: pre;"> </span>kigou=2;//最後に押された記号はひく</div>
<div><span style="white-space: pre;"> </span>});</div>
<div></div>
<div></div>
<div><span style="white-space: pre;"> </span>//*ボタン</div>
<div><span style="white-space: pre;"> </span>tbOpe[5].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogenum =calc(tf1.getText(),kigou);</div>
<div><span style="white-space: pre;"> </span>tf1.setText("");</div>
<div><span style="white-space: pre;"> </span>kigou=3;//最後に押された記号はかける</div>
<div><span style="white-space: pre;"> </span>});</div>
<div></div>
<div><span style="white-space: pre;"> </span>//わるボタン</div>
<div><span style="white-space: pre;"> </span>tbOpe[6].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>hogenum =calc(tf1.getText(),kigou);</div>
<div><span style="white-space: pre;"> </span>tf1.setText("");</div>
<div><span style="white-space: pre;"> </span>kigou=4;//最後に押された記号はわる</div>
<div><span style="white-space: pre;"> </span>});</div>
<div></div>
<div><span style="white-space: pre;"> </span>//ACボタン</div>
<div><span style="white-space: pre;"> </span>tbOpe[2].setOnAction((ActionEvent event)-&gt;{</div>
<div><span style="white-space: pre;"> </span>tf1.setText("");</div>
<div><span style="white-space: pre;"> </span>//l1.setText("");</div>
<div><span style="white-space: pre;"> </span>hogenum=0;</div>
<div><span style="white-space: pre;"> </span>hogestr="";</div>
<div><span style="white-space: pre;"> </span>kigou=0;</div>
<div><span style="white-space: pre;"> </span>pushEqual=false;</div>
<div><span style="white-space: pre;"> </span>pushDot=false;</div>
<div><span style="white-space: pre;"> </span>});</div>
<div></div>
<div><span style="white-space: pre;"> </span>Scene scene = new Scene(pane,400,300);//シーンのサイズ</div>
<div></div>
<div><span style="white-space: pre;"> </span>myStage.setTitle("電子計算機");</div>
<div><span style="white-space: pre;"> </span>myStage.setScene(scene);</div>
<div><span style="white-space: pre;"> </span>myStage.show();</div>
<div><span style="white-space: pre;"> </span>}</div>
<div></div>
<div><span style="white-space: pre;"> </span>/*--- 関数 ---*/</div>
<div></div>
<div><span style="white-space: pre;"> </span>public double calc(String tf1,int kigou) {</div>
<div><span style="white-space: pre;"> </span>System.out.println("here is in funcion calc");</div>
<div><span style="white-space: pre;"> </span>if (kigou==0) {</div>
<div><span style="white-space: pre;"> </span>hogenum = hogenum + Double.parseDouble(tf1);</div>
<div><span style="white-space: pre;"> </span>}else if (kigou==1) {</div>
<div><span style="white-space: pre;"> </span>hogenum = hogenum + Double.parseDouble(tf1);</div>
<div><span style="white-space: pre;"> </span>}else if(kigou==2) {</div>
<div><span style="white-space: pre;"> </span>hogenum = hogenum - Double.parseDouble(tf1);</div>
<div><span style="white-space: pre;"> </span>}else if(kigou==3) {</div>
<div><span style="white-space: pre;"> </span>hogenum = hogenum * Double.parseDouble(tf1);</div>
<div><span style="white-space: pre;"> </span>}else if(kigou==4) {</div>
<div><span style="white-space: pre;"> </span>hogenum = hogenum * Double.parseDouble(tf1);</div>
<div><span style="white-space: pre;"> </span>}</div>
<div><span style="white-space: pre;"> </span>pushDot=false;</div>
<div></div>
<div><span style="white-space: pre;"> </span>System.out.println("hogenumはいま"+hogenum);</div>
<div><span style="white-space: pre;"> </span>System.out.println("kigouはいま"+kigou);</div>
<div><span style="white-space: pre;"> </span>System.out.println("pushDotはいま"+pushDot);</div>
<div></div>
<div><span style="white-space: pre;"> </span>return hogenum;</div>
<div><span style="white-space: pre;"> </span>}</div>
<div>}</div>
<div></div>]]>
    </description>
    <category>実践2</category>
    <link>https://apikarasumaru.ko-me.com/%E5%AE%9F%E8%B7%B52/%E5%AE%9F%E8%B7%B52-15-%20%E8%87%AA%E4%BD%9C%E8%A8%88%E7%AE%97%E6%A9%9F%E3%81%9D%E3%81%AE3</link>
    <pubDate>Sat, 27 Feb 2021 22:21:44 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/102</guid>
  </item>
    <item>
    <title>android studio(7) プリントのサンプルを打ち込む2</title>
    <description>
    <![CDATA[<div>sample6bはことりんにそのまま変換できずエラーが出るプログラム</div>
<div>変数はすべてことりんでは宣言されていないといけないらしい</div>
<div>　</div>
<div><hr /><hr /></div>
<div>UMLの図</div>
<div>Unified Modeling Language　</div>
<div>　</div>
<div><a href="http://objectclub.jp/technicaldoc/uml/java2uml" title="">http://objectclub.jp/technicaldoc/uml/java2uml</a></div>
<div>1回これを読んでおくこと</div>
<div>　</div>
<div><hr /></div>
<div>エクリプスさんがプラグインでこれを作れる</div>
<div>いまのバージョンだと修正しないとエラーになるらしい</div>
<div>　</div>
<div>JDFSDKとかいうのをいれないといけないらしい</div>
<div>　</div>
<div>下準備：</div>
<div>ヘルプ</div>
<div>新規ソフトウエアのインスト</div>
<div>http://download.eclipse.org/releases/2019-09/</div>
<div>を入力</div>
<div>GEFを入力</div>
<div>これを選ぶ</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022715.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582786743/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div>あまてらすなんとかがよく使われるUML図プラグイン</div>
<div></div>
<div>C:\pleiades\eclipse\dropins\AmaterasModeler\eclipse\plugins</div>
<div>ここに、zipファイル(AmaterasUML_1.3.4-20200227T042128Z-001.zip)の中に入っていたやつをいれる</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022716.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582786761/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div>新規</div>
<div>そのた</div>
<div>あまてらすUML</div>
<div>クラス図</div>
<div>　</div>
<div>左側からドロップして使う</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022717.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582786777/" alt="" />&nbsp;<br />
<br />
</a>でもやっぱりバグがあって保存したの開くと、ないらしいな。</div>
<div>　</div>
<div><hr /><hr /></div>
<div></div>
<div>基本情報処理のメイズの問題はいい問題</div>
<div>いちどやってみるといいらしい</div>
<div>　</div>
<div>検定の問題はよいコードじゃなくて問題のための問題</div>
<div>無駄な処理をわざとしている</div>
<div>それをよろしいように直そうという問題だったりする</div>
<div>だからプログラムが得意なひとほどハテナになる</div>
<div>ええプログラムがのってる訳でなく、悩ますためのコードが載ってると考える</div>
<div>　</div>
<div><a href="https://www.fe-siken.com/kakomon/31_haru/pm11.html" title="">https://www.fe-siken.com/kakomon/31_haru/pm11.html</a></div>
<div>ここをよむ　</div>
<div>　</div>
<div><hr /><hr /></div>
<div>話は戻ってlesson1 <strong>sample6b.java</strong><br />
　</div>
<div>エラーさんがでたが、</div>
<div>①ボタンの処理だから</div>
<div>&nbsp;bt.<span style="color: #ff0000;">setOnTouchListener</span>(new SampleTouchListener());</div>
<div>じゃなくて</div>
<div>&nbsp;bt.<span style="color: #ff0000;">setOnClickListener</span>(new SampleClickListener());</div>
<div>②OnClickListenerのなかには</div>
<div><span style="color: #ff0000;">onClick</span>がないといけない決まり</div>
<div>　</div>
<div>class SampleTouchListener implements View.OnTouchListener{</div>
<div>&nbsp; &nbsp; public void <span style="color: #ff0000;">onClick</span>(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; tv.setText("いらっしゃいませ");</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div>　&nbsp;</div>
<div>できた</div>
<div><strong>---&gt;sample6B.java</strong></div>
<div>&nbsp;&nbsp;</div>
<div>package com.example.lesson1;</div>
<div></div>
<div>import android.os.Bundle;</div>
<div>import android.view.MotionEvent;</div>
<div>import android.view.View;</div>
<div>import android.widget.Button;</div>
<div>import android.widget.LinearLayout;</div>
<div>import android.widget.TextView;</div>
<div></div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div></div>
<div>public class Sample6B extends AppCompatActivity {</div>
<div>&nbsp; &nbsp; TextView tv;</div>
<div>&nbsp; &nbsp; Button bt;</div>
<div></div>
<div>&nbsp; &nbsp; public void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; LinearLayout l1 = new LinearLayout(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; l1.setOrientation(LinearLayout.VERTICAL);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(l1);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; tv = new TextView(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; tv.setText("いらっしゃいませ");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; l1.addView(tv);</div>
<div></div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; bt = new Button(this);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; bt.setText("初期状態に戻す");</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; bt.setOnClickListener(new SampleClickListener());</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; l1.addView(bt);</div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div>&nbsp; &nbsp; public boolean onTouchEvent(MotionEvent e) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if (e.getAction() == MotionEvent.ACTION_DOWN) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tv.setText("こんにちは");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; } else if (e.getAction() == MotionEvent.ACTION_UP) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tv.setText("さようなら");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; return true;</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; class SampleClickListener implements View.OnClickListener {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tv.setText("いらっしゃいませ");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div></div>
<div>}</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>もうひとつエラーをしていて、</div>
<div>&nbsp; &nbsp; class SampleClickListener implements View.OnClickListener {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tv.setText("いらっしゃいませ");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; }</div>
<div>を、</div>
<div>public class Sample6B extends AppCompatActivity {</div>
<div>の<strong>外側</strong>に置いてしまっていた。</div>
<div>内側が正解である。</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022718.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582786872/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div>lesson3</div>
<div>&rarr;空のアクティビティ</div>
<div>&rarr;javaを選択</div>
<div>&nbsp;</div>
<div>レイアウトエディターを使った画面周りの作成。</div>
<div>　</div>
<div>サンプルプログラムはいつもHello worldと表示される</div>
<div>マニフェストをみると.MainActivityを呼び出している</div>
<div>&nbsp;</div>
<div>MainActivityの中身---&gt;<br />
&nbsp;</div>
<div>package com.example.lesson3;</div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div>import android.os.Bundle;</div>
<div></div>
<div>public class MainActivity extends AppCompatActivity {</div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_main);</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div>　</div>
<div><hr /></div>
<div>フォルダres</div>
<div>layout</div>
<div>activity_main.xmlを開く</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022720.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582786934/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div>シーンビルダーが内臓されているようなもの。</div>
<div>　</div>
<div>コンストレイントレイアウトというのを推しているらしいのだが使いづらいらしい</div>
<div>相対位置でレイアウトするらしい</div>
<div>いっこ動かすとぐちゃぐちゃになって使いづらいらしい</div>
<div>　</div>
<div>始めはリニアレイアウトでやりましょう。<br />
ただ軽いので、開発では最後にコンストに変換するらしい。<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022721.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582786987/" alt="" /><br />
</a></div>
<div>　<br />
これを</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022722.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582787032/" alt="" /></a></div>
<div>こんな風に</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022723.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582787052/" alt="" /></a> <br />
　</div>
<div>ここは、こんすとレイアウト用の属性なのでさっぱりと消す</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022724.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582787082/" alt="" /></a></div>
<div>/&gt;は要るようだ</div>
<div>　</div>
<div><hr /></div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022725.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582787152/" alt="" /></a> <br />
　</div>
<div>ここをバーティカルにして縦長いのに固定しますよ</div>
<div>ボタンを追加</div>
<div></div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022726.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582787178/" alt="" /></a></div>
<div></div>
<div>sizeをかえたかったら検索でsizeとすると、</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022727.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582787195/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div>ボタンをクリックしたときの作業</div>
<div>まあidをつけますか</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022728.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582787220/" alt="" /></a> <br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022729.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582788598/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div>じゃあMainActivity.javaに移動して</div>
<div>宣言などしますよ</div>
<div>　</div>
<div>public class MainActivity extends AppCompatActivity {</div>
<div>&nbsp; &nbsp; <span style="color: #ff0000;">private TextView myText;</span></div>
<div><span style="color: #ff0000;">&nbsp; &nbsp; private Button myBtn1;</span></div>
<div>こうだ</div>
<div>　</div>
<div>newとかはいらないのですよ</div>
<div>　</div>
<div><hr /></div>
<div></div>
<div>バーティカルになってなかったので</div>
<div>ボタンが横に配置されていた<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022730.png" title=""><img src="//karasumaru.ko-me.com/Img/1582788614/" alt="" /></a></div>
<div>　</div>
<div>直りました。</div>
<div>　</div>
<div>ボタンに色を付けるときは</div>
<div>検索でbackground</div>
<div>#からカラーコードを入れてやる<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022731.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582788631/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div>&nbsp;myText = findViewById(R.id.myText);</div>
<div>Rとはリソース</div>
<div>赤地になることがあるが気にしなくていい</div>
<div>ビルドができたら解消されるらしい</div>
<div>　</div>
<div>Rはアンドロイドスタジオさんがつくったリソースというオブジェクトさん</div>
<div>サブカテゴリみたいな感じでidがついてるらしい</div>
<div>　</div>
<div><span style="color: #ff0000;">面接ではアンドロイドスタジオでつくったものをみせるとはやい。</span></div>
<div>　</div>
<div>デザインの画面の青っぽいほうは枠組みたいのらしい。<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022732.png" title=""><img src="//karasumaru.ko-me.com/Img/1582788651/" alt="" /></a></div>
<div>ここでも切り替えられるよ。</div>
<div>　</div>
<div><hr /></div>
<div>なおxmlなので//はコメントアウトじゃないよ</div>
<div>&lt;!----&gt;<br />
ですよ</div>
<div>コメント部分を選択状態で、ctrl+/でコメントアウトの付け外しができるよ。</div>
<div>　</div>
<div><hr /></div>
<div>すこしあそんでみますか<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022733.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582788677/" alt="" /></a></div>
<div>　</div>
<div>ボタン2を増やしたが</div>
<div>レンダリングが進まなかったので</div>
<div>6：Logcatをみたら</div>
<div>エラーがいっぱい。</div>
<div>　</div>
<div>&nbsp;Caused by: java.lang.<span style="color: #ff0000;">NullPointerException</span>: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a <span style="color: #ff0000;">null</span> object reference</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; at com.example.lesson3.MainActivity.onCreate(MainActivity.java:36)</div>
<div>　</div>
<div><span style="color: #ff0000;">Null</span>ですといっておられる</div>
<div>　</div>
<div>ボタンを追加したときは、<br />
　<br />
①ボタンを宣言する</div>
<div>&nbsp;private Button myBtn2;</div>
<div>②ボタンをこれする</div>
<div>&nbsp;myBtn2=findViewById(R.id.myBtn2);</div>
<div>　</div>
<div>追加したときはこの２つが必要なのだ。</div>
<div>　</div>
<div></div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022734.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582788690/" alt="" /></a></div>
<div>　</div>
<div>Logcatはここ&uarr;</div>
<div>　</div>
<div><hr /></div>
<div>あそんでみた。<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022735.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582788709/" alt="" /></a></div>
<div>　</div>
<div><strong>acticity_main.xml</strong></div>
<div>&nbsp;</div>
<div>&lt;?xml version="1.0" encoding="utf-8"?&gt;</div>
<div>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"</div>
<div>&nbsp; &nbsp; xmlns:app="http://schemas.android.com/apk/res-auto"</div>
<div>&nbsp; &nbsp; xmlns:tools="http://schemas.android.com/tools"</div>
<div>&nbsp; &nbsp; android:layout_width="match_parent"</div>
<div>&nbsp; &nbsp; android:layout_height="match_parent"</div>
<div>&nbsp; &nbsp; android:orientation="vertical"</div>
<div>&nbsp; &nbsp; tools:context=".MainActivity"&gt;</div>
<div></div>
<div>&nbsp; &nbsp; &lt;TextView</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/myText"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="wrap_content"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:text="Hello World!"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:textSize="30sp" /&gt;</div>
<div></div>
<div>&lt;!--&nbsp; &nbsp; aaaaa--&gt;</div>
<div>&lt;!--&nbsp; &nbsp; bbb--&gt;</div>
<div>&lt;!--&nbsp; &nbsp; --&gt;</div>
<div></div>
<div>&nbsp; &nbsp; &lt;Button</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/myBtn1"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:background="#ff0"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:text="ボ！タ！ン！！"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:textColor="#FF9800"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:textSize="36sp" /&gt;</div>
<div></div>
<div>&nbsp; &nbsp; &lt;Button</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/myBtn2"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:text="ざわ"</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; android:textSize="30sp" /&gt;</div>
<div></div>
<div>&lt;/LinearLayout&gt;&nbsp;</div>
<div>&nbsp;</div>
<div><hr /></div>
<div><strong>MainActivity.java</strong></div>
<div>&nbsp;</div>
<div>package com.example.lesson3;</div>
<div></div>
<div>import androidx.appcompat.app.AppCompatActivity;</div>
<div></div>
<div>import android.os.Bundle;</div>
<div>import android.view.View;</div>
<div>import android.widget.Button;</div>
<div>import android.widget.TextView;</div>
<div></div>
<div>public class MainActivity extends AppCompatActivity {</div>
<div>&nbsp; &nbsp; private TextView myText;</div>
<div>&nbsp; &nbsp; private Button myBtn1;</div>
<div>&nbsp; &nbsp; private Button myBtn2;</div>
<div>&nbsp; &nbsp; int i = 0;</div>
<div>&nbsp; &nbsp; String hoge="ざわ...";</div>
<div>&nbsp; &nbsp; int myTextSize = 36;</div>
<div></div>
<div>&nbsp; &nbsp; @Override</div>
<div>&nbsp; &nbsp; protected void onCreate(Bundle savedInstanceState) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; super.onCreate(savedInstanceState);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; setContentView(R.layout.activity_main);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myText = findViewById(R.id.myText);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myBtn1=findViewById(R.id.myBtn1);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myBtn2=findViewById(R.id.myBtn2);</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myBtn1.setOnClickListener(new View.OnClickListener() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(i==0) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("Good afternoon World");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myTextSize+=5;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setTextSize(myTextSize);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i=1;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText("Good night World");</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myTextSize+=5;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setTextSize(myTextSize);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i=0;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; });</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; myBtn2.setOnClickListener(new View.OnClickListener() {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hoge += hoge;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myTextSize = 36;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myText.setText(hoge);</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; });</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div></div>
<div></div>
<div><hr /></div>
<div>アルゴリズムの基本をJava、C#、Pythonで学ぼう - データを集計し、言語ごとの違いを知る - エンジニアHub｜若手Webエンジニアのキャリアを考える！</div>
<div><a href="https://employment.en-japan.com/engineerhub/entry/2020/02/27/103000" title="">https://employment.en-japan.com/engineerhub/entry/2020/02/27/103000</a></div>]]>
    </description>
    <category>android studio</category>
    <link>https://apikarasumaru.ko-me.com/android%20studio/androi%20studio-7-%20%E3%83%97%E3%83%AA%E3%83%B3%E3%83%88%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E3%82%92%E6%89%93%E3%81%A1%E8%BE%BC%E3%82%802</link>
    <pubDate>Fri, 26 Feb 2021 22:10:51 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/101</guid>
  </item>
    <item>
    <title>android studio(6) ことりん</title>
    <description>
    <![CDATA[<div><strong>super</strong>.onCreate(savedInstanceState);</div>
<div>&nbsp;</div>
<div>superとは親クラスのこと</div>
<div>ctrl+Bでそのすーぱー（親）がどうなってるのか見える</div>
<div>　</div>
<div>画面周りのクリエイトは親たちに任せておいて、自分たちはいわゆるがめんのしろいところをつくっていく</div>
<div>　</div>
<div></div>
<div><hr /></div>
<div>&nbsp;public <strong>boolean</strong> onTouch(){</div>
<div>ブーリアン型だから</div>
<div>return値は<strong>true</strong></div>
<div></div>
<div>&nbsp;return true;</div>
<div>&nbsp;</div>
<div><hr /></div>
<div>プリントlesson13,14はとばす（ふるいやりかたなので）</div>
<div>12まで</div>
<div>　</div>
<div><hr /><hr /></div>
<div>新しいことをしますよ</div>
<div>プロジェクトの中にエラーが1つでもあると動かないので、赤波線はいったんコメントアウトするよ</div>
<div>　</div>
<div><hr /></div>
<div>今のプロジェクトのコピーをとってそれをつかう</div>
<div>エクスプローラ</div>
<div>lesson1をコピー</div>
<div>lessen1bに</div>
<div>&nbsp;</div>
<div>ふつうはこのフォルダごとUSBに入れたりわたしたりはしないらしい</div>
<div>ファイル&rarr;zipファイルでエクスポート<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022709.png" title=""><img src="//karasumaru.ko-me.com/Img/1582773594/" alt="" /></a> <br />
　</div>
<div>これでわたす。</div>
<div>　</div>
<div>インポートするときはまず解凍</div>
<div>解凍したものが2重構造になっている</div>
<div><span style="color: #ff0000;">「インポート」というものじゃなくふつうに「開く」をする</span></div>
<div>lesson1のなかにlesson1が入っているような形</div>
<div>外側を選ぶとうまくいかない</div>
<div>内側を選ぶこと</div>
<div>　</div>
<div><hr /></div>
<div>左側の<br />
フォルダandroid</div>
<div>res</div>
<div>values/</div>
<div></div>
<div>mipmapというフォルダはそこに画像入れてくと自動でサイズ合わせてくれるらしい</div>
<div>　</div>
<div>今回はvaluesのcolorsをあけますよ</div>
<div>適当に色を変えてみる</div>
<div></div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022711.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582773614/" alt="" /></a> <br />
　</div>
<div>かわった</div>
<div>　</div>
<div><hr /></div>
<div>string.xml</div>
<div>タイトルを変える</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022712.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582773635/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div>これらはマニフェストに変数で入っている</div>
<div>定義したものをここで紐づけされている</div>
<div>ミップマップもかえると好きなアイコンに変えられるらしい</div>
<div>　</div>
<div>android stadioの公式言語はさいきんことりんになった</div>
<div>ことりんもやろう</div>
<div>javaとことりん両方できるのがコーダーとして強い</div>
<div>　</div>
<div><hr /></div>
<div>新しいプロジェクトをつくる</div>
<div>ことりんにしたので次つくるときはまたjavaにもどすのをわすれずに<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022713.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582773658/" alt="" /></a></div>
<div>　</div>
<div>ことりんは最後のセミコロンがない</div>
<div>1回java&rarr;ことりんにするともとには戻せない</div>
<div>　</div>
<div>javaができればことりんはできる。</div>
<div>javaでつくってことりんにしてみて、</div>
<div>ああこうなるんだなとおもいつつ</div>
<div>ことりんの本を一冊買って勉強すればいいとのこと。</div>
<div>　</div>
<div><span style="color: #ff0000;">なおjavaからことりんにしちゃうと、前のjavaファイルはなくなっちゃうから、クラスファイルをコピーしてやること。</span></div>
<div></div>
<div>コピーするときはjavaのlesson1から、ことりんのlesson1kにクラスファイルをこぴるが</div>
<div><span style="color: #ff0000;">MainActivityは上書きしないように。</span></div>
<div></div>
<div></div>
<div>変換したいファイルを右クリ&rarr;一番下のことりんに変換</div>
<div>複数でもできるらしい。</div>
<div></div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022714.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582773673/" alt="" /></a> <br />
　</div>
<div></div>]]>
    </description>
    <category>android studio</category>
    <link>https://apikarasumaru.ko-me.com/android%20studio/android%20studio-6-%20%E3%81%93%E3%81%A8%E3%82%8A%E3%82%93</link>
    <pubDate>Fri, 26 Feb 2021 22:02:04 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/99</guid>
  </item>
    <item>
    <title>android studio(6) ことりん</title>
    <description>
    <![CDATA[<div><strong>super</strong>.onCreate(savedInstanceState);</div>
<div>&nbsp;</div>
<div>superとは親クラスのこと</div>
<div>ctrl+Bでそのすーぱー（親）がどうなってるのか見える</div>
<div>　</div>
<div>画面周りのクリエイトは親たちに任せておいて、自分たちはいわゆるが画面のしろいところをつくっていく</div>
<div>　</div>
<div></div>
<div><hr /></div>
<div>&nbsp;public <strong>boolean</strong> onTouch(){</div>
<div>ブーリアン型だから</div>
<div>return値は<strong>true</strong></div>
<div></div>
<div>&nbsp;return true;</div>
<div>&nbsp;</div>
<div><hr /></div>
<div>プリントlesson13,14はとばす（ふるいやりかたなので）</div>
<div>12まで</div>
<div>　</div>
<div><hr /><hr /></div>
<div>新しいことをしましょう。</div>
<div>プロジェクトの中にエラーが1つでもあると動かないので、赤波線はいったんコメントアウトする。</div>
<div>　</div>
<div><hr /></div>
<div>今のプロジェクトのコピーをとってそれを利用する。</div>
<div>エクスプローラ</div>
<div>lesson1をコピー</div>
<div>lessen1bに</div>
<div>&nbsp;</div>
<div>普通はこのフォルダごとUSBに入れたりわたしたりはしないらしい</div>
<div>ファイル&rarr;zipファイルでエクスポート<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022709.png" title=""><img src="//karasumaru.ko-me.com/Img/1582773594/" alt="" /></a> <br />
　</div>
<div>これでわたす。</div>
<div>　</div>
<div>インポートするときはまず解凍</div>
<div>解凍したものが2重構造になっている</div>
<div><span style="color: #ff0000;">「インポート」というものじゃなくふつうに「開く」をする</span></div>
<div>lesson1のなかにlesson1が入っているような形</div>
<div>外側を選ぶとうまくいかない</div>
<div>内側を選ぶこと</div>
<div>　</div>
<div><hr /></div>
<div>左側の<br />
フォルダandroid</div>
<div>res</div>
<div>values/</div>
<div></div>
<div>mipmapというフォルダはそこに画像入れてくと自動でサイズ合わせてくれるらしい</div>
<div>　</div>
<div>今回はvaluesのcolorsを開ける</div>
<div>適当に色を変えてみる</div>
<div></div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022711.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582773614/" alt="" /></a> <br />
　</div>
<div>変わった。</div>
<div>　</div>
<div><hr /></div>
<div>string.xml</div>
<div>タイトルを変える</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022712.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582773635/" alt="" /></a></div>
<div>　</div>
<div><hr /></div>
<div>これらはマニフェストに変数で入っている</div>
<div>定義したものをここで紐づけされている</div>
<div>ミップマップもかえると好きなアイコンに変えられるらしい</div>
<div>　</div>
<div>android stadioの公式言語はさいきんことりんになった</div>
<div>ことりんもやろう</div>
<div>javaとことりん両方できるのがコーダーとして強い</div>
<div>　</div>
<div><hr /></div>
<div>新しいプロジェクトをつくる</div>
<div>ことりんにしたので次つくるときはまたjavaに戻すのを忘れずに。<br />
　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022713.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582773658/" alt="" /></a></div>
<div>　</div>
<div>ことりんは最後のセミコロンがない</div>
<div>1回java&rarr;ことりんにすると元には戻せない</div>
<div>　</div>
<div>javaができればことりんはできる。</div>
<div>javaで作ってことりんにしてみて、</div>
<div>ああこうなるんだなと思いつつ</div>
<div>ことりんの本を一冊買って勉強すればいいとのこと。</div>
<div>　</div>
<div><span style="color: #ff0000;">なおjavaからことりんにしちゃうと、前のjavaファイルはなくなっちゃうから、クラスファイルをコピーしてやること。</span></div>
<div></div>
<div>コピーするときはjavaのlesson1から、ことりんのlesson1kにクラスファイルをこぴるが</div>
<div><span style="color: #ff0000;">MainActivityは上書きしないように。</span></div>
<div></div>
<div></div>
<div>変換したいファイルを右クリ&rarr;一番下のことりんに変換</div>
<div>複数でもできるらしい。</div>
<div></div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022714.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582773673/" alt="" /></a> <br />
　</div>
<div></div>]]>
    </description>
    <category>android studio</category>
    <link>https://apikarasumaru.ko-me.com/android%20studio/android%20studio-6-%20%E3%81%93%E3%81%A8%E3%82%8A%E3%82%93_100</link>
    <pubDate>Fri, 26 Feb 2021 22:02:04 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/100</guid>
  </item>
    <item>
    <title>android studio(5)　プリントのサンプルを打ち込む</title>
    <description>
    <![CDATA[<div>ここはandroidにしておく</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022705.png" title=""><img src="//karasumaru.ko-me.com/Img/1582770476/" alt="" /></a> <br />
&nbsp;<br />
何かのはずみに触ってしまってandroid以外になるとハテナになるので注意。<br />
&nbsp;</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022706.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582770489/" alt="" /></a></div>
<div></div>
<div><hr />manifests</div>
<div>指示書のこと</div>
<div>このフォルダには1つのファイルしかないので、ダブルクリックすると自動でそのファイルが開く</div>
<div>　</div>
<div>このアプリはカメラを使うとかネットワークを使うとかそういう宣言を全部書いているファイルらしい</div>
<div>アプリ全体に対する宣言書とおもっていい　</div>
<div>　</div>
<div>アクティビティの部分を私たちはよく変える</div>
<div>画面のこと。</div>
<div>この部分</div>
<div>　　</div>
<div>&lt;activity android:name=".Rensyu2"&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;intent-filter&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;action android:name="android.intent.action.MAIN" /&gt;</div>
<div></div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;category android:name="android.intent.category.LAUNCHER" /&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/intent-filter&gt;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/activity&gt;</div>
<div>　　</div>
<div>アクティビティ宣言は画面の数だけ作ることになる</div>
<div>　</div>
<div><hr /></div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022707.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582770534/" alt="" /></a> <br />
　</div>
<div>ここに動かすファイル名を入れる</div>
<div>ドット始まり。</div>
<div>ドットとは「同じアプリの中の」という意味らしい</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022708.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582770546/" alt="" /></a></div>
<div>　<br />
自動生成された分は触りませんよ。<br />
　</div>
<div><hr /></div>
<div>プリントのsample1をみていく。</div>
<div>　</div>
<div>AppCompatActivityを使う</div>
<div></div>
<div>onCreate(Bundle savedInstanceState){</div>
<div>bundleは束ねたものの意</div>
<div>ここらへんはそういう型だとおもっておく。</div>
<div>　</div>
<div>今日の後半からシーンビルダみたいのを使うよ</div>
<div>　</div>
<div>&nbsp;setContentView(ll);つくったものをセットする。必要。</div>
<div>&nbsp;LinearLayout　まっすぐ並べるpaneみたいなもの。</div>
<div>　</div>
<div>アンドロイドスタジオでは、javaと、アンドロイドスタジオのクラスが乗っている。</div>
<div>　</div>
<div>普通はメソッドの上でSHIFT+f1でリファレンスが出てくるらしい。</div>
<div>でてこないな</div>
<div>ctrl+Qでもリンクがでてくるらしい</div>
<div>でてこないな</div>
<div>　</div>
<div>android reference</div>
<div><a href="https://developer.android.com/reference" title="">https://developer.android.com/reference</a></div>
<div>&nbsp;</div>
<div><hr /></div>
<div>実際スマホではclickでなくon touchをよくつかう</div>
<div>sample5 ボタンタッチ</div>
<div>sample6 画面タッチ</div>
<div>　</div>
<div>6までいったら6ｂとして初期に戻すボタンまで作る</div>
<div>おしたらこんにちは</div>
<div>はなしたらさようなら</div>
<div>戻すボタンをおしたらはじめのいらっしゃいませにしてみましょう。</div>
<div>　</div>
<div>rensyu2の先は新しいプロジェクトで作る。</div>
<div>　</div>
<div></div>]]>
    </description>
    <category>android studio</category>
    <link>https://apikarasumaru.ko-me.com/android%20studio/android%20studio-5-%E3%80%80%E3%83%97%E3%83%AA%E3%83%B3%E3%83%88%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E3%82%92%E6%89%93%E3%81%A1%E8%BE%BC%E3%82%80</link>
    <pubDate>Fri, 26 Feb 2021 21:54:36 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/98</guid>
  </item>
    <item>
    <title>エクリプス(6) プロジェクトをGドライブ経由でDLするとxmlファイルになり読み込めない件</title>
    <description>
    <![CDATA[<div>計算機　先生版</div>
<div>lookupというメソッド</div>
<div>グリッドペインのIDを拾ってくるとか</div>
<div>&nbsp;</div>
<div>fxml?で作ったのは内部でnewされている</div>
<div>ので自分でnewする必要ない</div>
<div>　</div>
<div>ボタンのところのラベルを取ってきてそれを変数に入れているらしい</div>
<div></div>
<div><hr />エクリプスで作ったプロジェクトがグーグルドライブ経由でDLすると勝手にxmlファイルにしちゃって読み込めない件:<br />
&nbsp;</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022701.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582770378/" alt="" /></a></div>
<div>この.xmlの拡張子をとる</div>
<div>_を.にかえる</div>
<div>　</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022702.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582770392/" alt="" /></a> <br />
&nbsp;</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022704.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582770406/" alt="" /></a> <br />
&nbsp;</div>
<div>　　</div>
<div><hr />プロジェクト名が同じだとインポートできないということもありうるらしい</div>
<div>&rarr;その場合、</div>
<div><strong>.project</strong>をサクラで開く</div>
<div><span style="white-space: pre;"> </span>&lt;name&gt;<span style="color: #ff0000;">calculator</span>&lt;/name&gt;</div>
<div>ここが名前なので自分がもってないプロジェクトの名前にする。</div>
<div></div>
<div>ファイル&rarr;インポート&rarr;既存プロジェクトをワークスペース　<br />
&nbsp;</div>
<div><a target="_blank" href="//karasumaru.ko-me.com/File/2020022703.PNG" title=""><img src="//karasumaru.ko-me.com/Img/1582770428/" alt="" /></a></div>
<div>　</div>
<div>&nbsp;</div>
<div></div>]]>
    </description>
    <category>エクリプス</category>
    <link>https://apikarasumaru.ko-me.com/%E3%82%A8%E3%82%AF%E3%83%AA%E3%83%97%E3%82%B9/%E3%82%A8%E3%82%AF%E3%83%AA%E3%83%97%E3%82%B9-6-%20%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%82%92g%E3%83%89%E3%83%A9%E3%82%A4%E3%83%96%E7%B5%8C%E7%94%B1%E3%81%A7dl</link>
    <pubDate>Tue, 23 Feb 2021 21:50:21 GMT</pubDate>
    <guid isPermaLink="false">apikarasumaru.ko-me.com://entry/97</guid>
  </item>

    </channel>
</rss>