I am working on a project using geckoview in android studio. The app keeps crashing when I reach the containing activity. using log cat I found out that it gives me the following error
FATAL EXCEPTION: main
Process: app, PID: 2815
java.lang.RuntimeException: Unable to start activity ComponentInfo{project name}: android.view.InflateException: Binary XML file line #27: Binary XML file line #27: Error inflating class org.mozilla.gecko.GeckoView
I dont know how to fix this or what does it mean or what to do...
Here is my code, I hope it helps
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_page);
Button Nav=(Button) findViewById(R.id.Nav);
GeckoView geckoView = (GeckoView) findViewById(R.id.geckoview);
GeckoSession session = new GeckoSession();
geckoView.setSession(session);
session.loadUri("http://google.com");
}
XML
<org.mozilla.gecko.GeckoView
android:id="#+id/geckoview"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="82dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/guideline2" />
Thank you in advance..
Change Geckoview in xml as below
<org.mozilla.geckoview.GeckoView
android:id="#+id/geckoview"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="82dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/guideline2" />
Related
unresolved reference
val name = nameInput.editableText.toString() // getting error in this line
val intent = Intent (this, BirthdayGreetingsActivity::class.java)
startActivity(intent)
Try this
in your XML, you will have a view like
<EditText
android:id="#+id/nameInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:ems="10"
android:inputType="textPersonName"
android:minHeight="48dp"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
in your activity class
add this
val name : EditText = findViewById(R.id.nameInput)
and get the input text with
name.text.toString()
I've been working on an app, all the code seems to be fine, xml and java. When i run the app in an emulator, my splash screen is no longer running, when i click on a button, it takes me to the right page but does not show me the layout of the file.
When i edit the xml file layout, the changes are not being shown on the app when it runs in the emulator.
i'll post the code below:
This code is for the xml layout of the page:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#drawable/bgapp"
tools:context=".complain">
<ImageView
android:layout_width="310dp"
android:layout_height="86dp"
android:layout_marginLeft="45dp"
android:src="#drawable/bfcfulllogotransparent" />
<ImageView
android:layout_width="79dp"
android:layout_height="76dp"
android:layout_marginLeft="160dp"
android:layout_marginTop="500dp"
android:src="#drawable/bfchandtransparent"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Making a Complaint"
android:textAllCaps="false"
android:layout_marginTop="75dp"
android:textAlignment="center"
android:textColor="#ffff"
android:textStyle="bold"
android:textSize="18dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_marginHorizontal="10dp"
android:textAlignment="center"
android:textColor="#ffff"
android:textAllCaps="false"
android:text="There may be times when you feel that you are not happy with the services you have been provided, it is your right to be able to make a complaint about these issues.
"
android:fontFamily="sans-serif"
android:textSize="16dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="190dp"
android:layout_marginHorizontal="10dp"
android:textAlignment="center"
android:textColor="#ffff"
android:textAllCaps="false"
android:text="There are a number of ways that you can make a complaint…"
android:fontFamily="sans-serif"
android:textSize="16dp"/>
<Button
android:id="#+id/butthow"
android:layout_width="273dp"
android:layout_height="66dp"
android:layout_marginLeft="55dp"
android:layout_marginTop="280dp"
android:background="#drawable/custom_button"
android:text="How to make a complaint"
android:textAllCaps="false"
android:textColor="#ffff"
android:textSize="18dp"
android:textStyle="bold"/>
<Button
android:id="#+id/buttwhat"
android:layout_width="273dp"
android:layout_height="66dp"
android:layout_marginLeft="55dp"
android:layout_marginTop="380dp"
android:background="#drawable/custom_button"
android:text="What happens to your complaint"
android:textAllCaps="false"
android:textColor="#ffff"
android:textSize="18dp"
android:textStyle="bold"/>
</RelativeLayout>
This code is for the xml for the splash screen:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:background="#drawable/bgapp"
tools:context=".splashscreen">
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:text="Childrens Guide"
android:textColor="#ffff"
android:textSize="35dp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/textView4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView4" />
<TextView
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="214dp"
android:text="A guide for children living in foster care"
android:textAlignment="center"
android:textColor="#ffff"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/imageView5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView3" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="350dp"
android:layout_height="100dp"
android:layout_marginStart="15dp"
android:layout_marginTop="27dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="133dp"
android:src="#drawable/bfcfulllogotransparent"
app:layout_constraintBottom_toTopOf="#+id/imageView6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="101dp"
android:layout_height="0dp"
android:layout_marginBottom="41dp"
android:src="#drawable/bfchandtransparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView4" />
<ImageView
android:id="#+id/imageView6"
android:layout_width="1000dp"
android:layout_height="200dp"
android:layout_marginStart="18dp"
android:layout_marginEnd="18dp"
android:layout_marginBottom="173dp"
android:src="#drawable/coverkids"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView4" />
</androidx.constraintlayout.widget.ConstraintLayout>
this is the java for the splashscreen:
package com.example.bfcchildrensguidenew;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
public class splashscreen extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splashscreen);
Thread myThread = new Thread() {
#Override
public void run() {
try {
sleep(3000 );
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
myThread.start();
}
}
You can not call startActivity method outside of main thread(UI thread), it will crash.
User handler instead a Thread.
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
#Override
public void run() {
Intent intent = new Intent (getApplicationContext(),MainActivity.this);
startActivity(intent);
}
});
|I just added new activity (chose settings template) when i created my app in my setting page there are some elements that aren't exist in my editor nor in xml code.
Screenshots
In App
In Editor
Code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/settings">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="4sp"
android:layout_marginRight="4sp"
android:weightSum="3"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RadioGroup
android:id="#+id/appLang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="35dp"
android:layout_marginEnd="35dp"
android:layout_marginRight="35dp"
android:layout_marginStart="35dp"
android:layout_marginLeft="35dp"
android:orientation="horizontal">
<TextView
android:id="#+id/applangtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/applangtextstring" />
<RadioButton
android:id="#+id/radio_indo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="#string/indoLang" />
<RadioButton
android:id="#+id/radio_english"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="#string/englishLang" />
</RadioGroup>
<RadioGroup
android:id="#+id/learnLang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="35dp"
android:layout_marginEnd="35dp"
android:layout_marginRight="35dp"
android:layout_marginStart="35dp"
android:layout_marginLeft="35dp"
android:orientation="horizontal">
<TextView
android:id="#+id/learnlangtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/learnLangText" />
<RadioButton
android:id="#+id/learn_radio_indo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButton2Clicked"
android:text="#string/indoLang" />
<RadioButton
android:id="#+id/learn_radio_english"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButton2Clicked"
android:text="#string/englishLang" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Any idea?
Solved
There was some extra lines in my settingsActivity file in ocCreate() function after removing them and rebuild my app UI issue was solved.
My current onCreate() function is like this now:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
// here was some lines regarding to Topbar
}
Note: what was connection between topbar(toolbar) and UI issue
personally i don't know but my problem solved after removing that and
that's all matter :)
I have a XML file like below. I want to make the first layout clickable, I used android:clickable="true", but click is not working on whole part, only some part is responding to click. How to make the whole Layout clickable?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical">
<LinearLayout
android:id="#+id/clicableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/task_finish"
android:background="#color/colorPrimary"
android:clickable="true"
android:orientation="vertical">
<TextView
android:id="#+id/task_title"
android:layout_width="195dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:clickable="true"
android:text="Hello"
android:textColor="#color/HeadingColor"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/DateText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10dp"
android:text="Date"
android:textColor="#color/DateColor"
android:textStyle="italic|bold" />
<TextView
android:id="#+id/TimeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="Time"
android:textColor="#color/TimeColor"
android:textStyle="italic|bold" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Ask more clearly about the problem. If you want to click on the LinearLayout then set an onClickListener on the id of the LinearLayout.
you need to implement on click listener , one way of achieving this is by the following code :
yourView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
//what after the view got clicked
}
});
I am trying to start a new activity but I am getting this error for the activity which I want to start. This XML code is for the activity which I want to start.
Here is the error log:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.SandFoil.kaizen/com.SandFoil.kaizen.Registeration}: android.view.InflateException: Binary XML file line #94: addView(View, LayoutParams) is not supported in AdapterView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: android.view.InflateException: Binary XML file line #94: addView(View, LayoutParams) is not supported in AdapterView
Caused by: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
at android.widget.AdapterView.addView(AdapterView.java:495)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:862)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.SandFoil.kaizen.Registeration.onCreate(Registeration.java:11)
at android.app.Activity.performCreate(Activity.java:6672)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
and here's my XML code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.SandFoil.kaizen.Registeration"
android:id="#+id/activity_registeration"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="8dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_name_edittext"
android:inputType="text"
android:textSize="20sp"
android:layout_marginBottom="10dp"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Phone">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_phone_edittext"
android:inputType="phone"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="E-mail">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_email_edittext"
android:inputType="textEmailAddress"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Date of birth(dd/mm/yyyy)">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_date_of_birth_edittext"
android:inputType="date"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="Gender: "
android:layout_marginRight="10dp"/>
<android.support.v7.widget.AppCompatSpinner
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/registeration_gender_spinner"
android:layout_marginBottom="10dp">
</Spinner>
</android.support.v7.widget.AppCompatSpinner>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Mother's name('N/A' if you are not a student)">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_mother_name_edittext"
android:inputType="text"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Child's name('N/A' if you are not a parent)">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_child_name_edittext"
android:inputType="text"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/registeration_password_edittext"
android:inputType="textPassword"
android:textSize="20sp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<Button
android:background="#drawable/capsule_button"
android:layout_width="220dp"
android:layout_height="50dp"
android:text="Login"
android:textColor="#android:color/white"
android:textSize="25sp"
android:layout_marginBottom="10dp"/>
</LinearLayout>
</ScrollView>
Googled all possible solutions but none worked. Can somebody please fix this and tell me something about this issue ?? And Here is the java file for this XML
package com.SandFoil.kaizen;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class Registeration extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registeration);
}
}
The implementation of "spinner" is wrong here in XML. I copied that code from somewhere on the internet. I will be editing this answer and posting the link to that wrong implementation for reference as soon as i find it again. Remove that "spinner" code from this XML and it will work.