In this forum that's three question about that I know, but none solved my problem. They didnt help me.
I'm trying learn android, I coded something but it doesnt work on my phone anytime. Everytime it says "has stopped working"
my codes :
Java
package com.example.murathan.oyun;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Button;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
Button javauyu, javasavas, javayemek;
TextView javaeylem, javaistatistik;
Karakter k;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
k = new Karakter();
javauyu = (Button)findViewById(R.id.bt_uyu);
javasavas = (Button)findViewById(R.id.bt_savas);
javayemek = (Button)findViewById(R.id.bt_yemek);
javaeylem = (TextView)findViewById(R.id.tv_eylem);
javaistatistik = (TextView)findViewById(R.id.tv_istatistik);
javauyu.setOnClickListener(this);
javayemek.setOnClickListener(this);
javasavas.setOnClickListener(this);
k.kilo = 50;
k.action = 10;
k.attackD = 80;
javaistatistik.setText(k.toString());
}
@Override
public void onClick(View v) {
if (v.getId() == javauyu.getId())
{
javaeylem.setText(k.komutuyu());
}
else if (v.getId() == javasavas.getId())
{
javaeylem.setText(k.komutsavas());
}
else if (v.getId() == javayemek.getId())
{
javaeylem.setText(k.komutye());
}
javaistatistik.setText(k.toString());
}
}
XML
<?xml version="1.0" encoding="utf-8"?>
<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"
android:gravity="center"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<TextView
android:id="@+id/tv_istatistik"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@string/size"
android:gravity="center"
android:padding="@string/pad"
android:text="@string/istatistik"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
>
<Button
android:id="@+id/bt_uyu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@string/size"
android:padding="@string/pad"
android:text="@string/b_uyu"
/>
<Button
android:id="@+id/bt_yemek"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@string/size"
android:padding="@string/pad"
android:text="@string/b_yemek"
/>
<Button
android:id="@+id/bt_savas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@string/size"
android:padding="@string/pad"
android:text="@string/b_savas"
/>
</LinearLayout>
<TextView
android:id="@+id/tv_eylem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@string/size"
android:padding="@string/pad"
android:text="@string/eylemyap"
/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
and Crash (LogCat)
08-18 21:17:45.816 22618-22618/com.example.murathan.oyun E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.murathan.oyun, PID: 22618
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.murathan.oyun/com.example.murathan.oyun.MainActivity}: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class TextView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class TextView
Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class TextView
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 14 to dimension: type=0x3
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java)
at android.view.View.<init>(View.java)
at android.widget.TextView.<init>(TextView.java)
at android.widget.TextView.<init>(TextView.java)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:87)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:83)
at android.support.v7.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:177)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:102)
at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java)
at android.view.LayoutInflater.rInflate(LayoutInflater.java)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java)
at android.view.LayoutInflater.rInflate(LayoutInflater.java)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java)
at android.view.LayoutInflater.inflate(LayoutInflater.java)
at android.view.LayoutInflater.inflate(LayoutInflater.java)
at android.view.LayoutInflater.inflate(LayoutInflater.java)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.murathan.oyun.MainActivity.onCreate(MainActivity.java:16)
at android.app.Activity.performCreate(Activity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
please help me to solve my problem, i'm researching since 2 days but i cant solve that.
if there's any writing problem im sorry, im not English so I cant write very well.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…