私はkotlinを学習しています。それが起こる理由xmlのKotlinは動作しません
Could not find method clickItemHoro(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatImageView with id 'aries'
を:私はエラーを持っているボタンをクリックしたときに、私は、XML
<ImageView
android:id="@+id/aries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:tag="1"
android:onClick="clickItemHoro"
android:src="@drawable/aries" />
とフラグメント
class ChooseYourHoroscope : Fragment(){
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_welcome_old, container, false)
return view;
}
fun clickItemHoro(v: View?){
Log.e("clickItemHoro", v!!.tag.toString())
}
}
がありますか?コードは単純ですが、動作しません、なぜ私は理解できません
* Kotlin xmlの中のonClick * ...親や祖先コンテキストに過ぎ... *、* ...それは、Javaで動作しない動作しないのですか? – Selvin
私は理解した、タンク! – g71132
[http://stackoverflow.com/questions/14139774/android-app-crashing-fragment-and-xml-onclick](http://stackoverflow.com/questions/14139774/android-app-crashing-fragment-and -xml-onclick)refこのリンクは言った。 – Jacob