Android Studioボタンジャンプ機能の実現、クリック後のフラッシュバック問題の処理
アンドロイドシロ、授業はアプリを作る必要があります.する時、1つの機能をやり遂げます:ボタンをクリックして、新しいインタフェースにジャンプします.チュートリアルを参照:https://blog.csdn.net/baidu_30258569/article/details/49409145 https://blog.csdn.net/mghhz816210/article/details/50373698 https://blog.csdn.net/qq_20737519/article/details/50145687
はい、新しいインタフェースのxmlファイルでこう書きました.
テスト用のテキストは1行しかありません.何の問題もないようです.そしてrunは、ボタンをクリックしてフラッシュバックします.エラーメッセージは次のとおりです.
長い間見ていて、大丈夫だと思います.このlayout-widthも指定されているようです.そして長い間調べていたらtextの幅も指定されていました.このように変更しました
ジャンプに成功します.
はい、新しいインタフェースのxmlファイルでこう書きました.
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".identify">
<TextView
android:text=" , "/>
android.support.constraint.ConstraintLayout>
テスト用のテキストは1行しかありません.何の問題もないようです.そしてrunは、ボタンをクリックしてフラッシュバックします.エラーメッセージは次のとおりです.
05-22 14:36:41.441 22856-22856/com.example.coder_cxk.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.coder_cxk.myapplication, PID: 22856
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.coder_cxk.myapplication/com.example.coder_cxk.myapplication.identify}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: You must supply a layout_width attribute.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3027)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:101)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:73)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
長い間見ていて、大丈夫だと思います.このlayout-widthも指定されているようです.そして長い間調べていたらtextの幅も指定されていました.このように変更しました
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".identify">
<TextView
android:id="@+id/test_text"
android:layout_width="wrap_content"
android:layout_height="73dp"
android:text=" , "/>
android.support.constraint.ConstraintLayout>
ジャンプに成功します.