国連アフリカ経済委員会は、「イノベーション・プライズ・フォー・アフリカ」の受賞者として、「ハエ」を利用する飼料の製造技術を開発したアグリプロテイン・テクノロジーズを選んだ。
この技術は、特殊な方法で飼育した「ハエ」によって、廃棄された食品や廃棄物に含まれる血液、内臓、肥やしなどを家畜の飼料に変換するというもの。廃棄物を食べて育ったハエの幼虫を回収して乾燥させ、ひいて粉にしてから、コーンフレーク状に成形。飼料メーカー向けに出荷する。
乾燥させた幼虫の成分の組成は、一般に飼料として使われる魚粉と同じだという。
2013年5月14日火曜日
2013年5月8日水曜日
複数のボタンを同時にタップさせないようにする
1つの画面にボタンを2つ配置する。
ボタンを同時のタップすると・・・・・2つのボタンが同時に効いてしまう。
今までこんなことあったっけ!?
と思い調べてみました。
ちなみにAndroid4.0.3でコンパイルしてました。
2.3.3の時はそんなことなかったはずなので、
2.3.3でコンパイルし直して、同様にボタンを同時押ししてみた。
・・・・・起きない。
調べてみると・・・・あった。
3.0かららしいが、どうやらイベントはデフォルトでそれぞれのViewごとで受け付けられるようになっているぽい。
2.3.3までは、あるViewをタップしている間、別のViewはイベントを受け付けられなかったが、
3.0以降はデフォルトでイベント中に別のイベントも受け付けるらしい。
別のViewを受け付けないようにするためには、以下のように、親Viewの属性として「android:splitMotionEvents="false"」を追加する。
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:splitMotionEvents="false">
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button1"
android:id="@+id/button1"/>
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button2"
android:id="@+id/button2"/>
</LinearLayout>
これが書いてある子Viewはイベントを並行して処理しなくなる。
また、いちいちレイアウトに設定したくない場合は、以下のようにstyles.xmlにテーマ、およびスタイルとして設定してもよい。
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowEnableSplitTouch">false</item>
</style>
http://developer.android.com/about/versions/android-3.0.html
Split touch events
Previously, only a single view could accept touch events at one time. Android 3.0 adds support for splitting touch events across views and even windows, so different views can accept simultaneous touch events.
Split touch events is enabled by default when an application targets Android 3.0. That is, when the application has set either the android:minSdkVersion or android:targetSdkVersion attribute's value to "11".
However, the following properties allow you to disable split touch events across views inside specific view groups and across windows.
The android:splitMotionEvents attribute for view groups allows you to disable split touch events that occur between child views in a layout. For example:
<LinearLayout android:splitMotionEvents="false" ... >
...
</LinearLayout>
This way, child views in the linear layout cannot split touch events-only one view can receive touch events at a time.
The android:windowEnableSplitTouch style property allows you to disable split touch events across windows, by applying it to a theme for the activity or entire application. For example:
<style name="NoSplitMotionEvents" parent="android:Theme.Holo">
<item name="android:windowEnableSplitTouch">false</item>
...
</style>
When this theme is applied to an <activity> or <application>, only touch events within the current activity window are accepted. For example, by disabling split touch events across windows, the system bar cannot receive touch events at the same time as the activity. This does not affect whether views inside the activity can split touch events-by default, the activity can still split touch events across views.
For more information about creating a theme, read Applying Styles and Themes.
ボタンを同時のタップすると・・・・・2つのボタンが同時に効いてしまう。
今までこんなことあったっけ!?
と思い調べてみました。
ちなみにAndroid4.0.3でコンパイルしてました。
2.3.3の時はそんなことなかったはずなので、
2.3.3でコンパイルし直して、同様にボタンを同時押ししてみた。
・・・・・起きない。
調べてみると・・・・あった。
3.0かららしいが、どうやらイベントはデフォルトでそれぞれのViewごとで受け付けられるようになっているぽい。
2.3.3までは、あるViewをタップしている間、別のViewはイベントを受け付けられなかったが、
3.0以降はデフォルトでイベント中に別のイベントも受け付けるらしい。
別のViewを受け付けないようにするためには、以下のように、親Viewの属性として「android:splitMotionEvents="false"」を追加する。
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:splitMotionEvents="false">
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button1"
android:id="@+id/button1"/>
<Button android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button2"
android:id="@+id/button2"/>
</LinearLayout>
これが書いてある子Viewはイベントを並行して処理しなくなる。
また、いちいちレイアウトに設定したくない場合は、以下のようにstyles.xmlにテーマ、およびスタイルとして設定してもよい。
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowEnableSplitTouch">false</item>
</style>
http://developer.android.com/about/versions/android-3.0.html
Split touch events
Previously, only a single view could accept touch events at one time. Android 3.0 adds support for splitting touch events across views and even windows, so different views can accept simultaneous touch events.
Split touch events is enabled by default when an application targets Android 3.0. That is, when the application has set either the android:minSdkVersion or android:targetSdkVersion attribute's value to "11".
However, the following properties allow you to disable split touch events across views inside specific view groups and across windows.
The android:splitMotionEvents attribute for view groups allows you to disable split touch events that occur between child views in a layout. For example:
<LinearLayout android:splitMotionEvents="false" ... >
...
</LinearLayout>
This way, child views in the linear layout cannot split touch events-only one view can receive touch events at a time.
The android:windowEnableSplitTouch style property allows you to disable split touch events across windows, by applying it to a theme for the activity or entire application. For example:
<style name="NoSplitMotionEvents" parent="android:Theme.Holo">
<item name="android:windowEnableSplitTouch">false</item>
...
</style>
When this theme is applied to an <activity> or <application>, only touch events within the current activity window are accepted. For example, by disabling split touch events across windows, the system bar cannot receive touch events at the same time as the activity. This does not affect whether views inside the activity can split touch events-by default, the activity can still split touch events across views.
For more information about creating a theme, read Applying Styles and Themes.
登録:
投稿 (Atom)