App crashes when I press the textview - android

I have the following TextView
<TextView
android:id="#+id/LoginlinkLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical center_horizontal"
android:autoSizeMaxTextSize="45sp"
android:autoSizeMinTextSize="15sp"
android:autoSizeStepGranularity="2sp"
android:text="#string/Loginlink"
android:textAlignment="center"
android:textSize="15sp"
android:onClick="loginlinkLabelonClick"
android:clickable="true"/>
And this function
fun loginlinkLabelonClick(context:Context)
{
val urlString="http://www.google.gr"
val intent = Intent(Intent.ACTION_VIEW,Uri.parse(urlString)) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.`package`="com.android.chrome"
try
{
context.startActivity(intent)
}
catch(ex:ActivityNotFoundException)
{
intent.`package`= null
context.startActivity(intent)
}
}
The error message:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.reviewer.reviewer, PID: 27809
java.lang.IllegalStateException: Could not find method loginlinkLabelonClick(View) in a parent or ancestor Context for
android:onClick attribute defined on view class
android.support.v7.widget.AppCompatTextView with id 'LoginlinkLabel'
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:423)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:380)
at android.view.View.performClick(View.java:6291)
at android.view.View$PerformClick.run(View.java:24931)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
But as soon as I tap the textview the application crashes and I can't seem to find what's wrong.
I'm new to Java, kotlin and Android studio.
I had a previous experience with visual studio and c# and Java / kotlin feels a bit strange
Now I'm really trying to figure out how to open urls, but I'm having trouble getting it to work

Usually when you have a click method in the xml, the argument for the method in kotlin is a view instance, see more here. So your method should look like this:
fun loginlinkLabelonClick(view:View)
{
}

Related

IndexOutOfBoundsException for EditText setSelection Android

The Fragments crashes when trying to get the data using the location with the error below:
2022-05-26 00:42:46.057 30678-30678/com.example.android.politicalpreparedness E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.politicalpreparedness, PID: 30678
java.lang.IndexOutOfBoundsException: setSpan (5 ... 5) ends beyond length 0
at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1325)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:676)
at android.text.Selection.setSelection(Selection.java:96)
at android.text.Selection.setSelection(Selection.java:78)
at android.widget.EditText.setSelection(EditText.java:129)
at com.example.android.politicalpreparedness.representative.RepresentativeFragment$populateStatesInformation$1.onChanged(RepresentativeFragment.kt:119)
at com.example.android.politicalpreparedness.representative.RepresentativeFragment$populateStatesInformation$1.onChanged(RepresentativeFragment.kt:23)
at androidx.lifecycle.LiveData.considerNotify(LiveData.java:131)
at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:149)
at androidx.lifecycle.LiveData.setValue(LiveData.java:307)
at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
at androidx.lifecycle.LiveData$1.run(LiveData.java:91)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I am confused how this is causing an error. It's supposed to show the value that's in the adapter right?
Fragment Code :
private fun populateStatesInformation() {
val statesArray = requireContext().resources.getStringArray(R.array.states)
binding.addressState.setAdapter(ArrayAdapter(requireContext(), R.layout.layout_state_list_item, statesArray))
viewModel.address.observe(viewLifecycleOwner) {
var index = statesArray.indexOf(it.state)
if (index == -1) {
index = 0
}
binding.addressState.setSelection(index)
}
}
The XML Code for that text field.
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/address_state_layout"
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:hint="#string/address_state"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/address_zip_layout"
app:layout_constraintTop_toTopOf="#id/address_zip_layout">
<AutoCompleteTextView
android:id="#+id/address_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:ellipsize="end"
android:maxLines="1"
tools:ignore="Deprecated,LabelFor" />
</com.google.android.material.textfield.TextInputLayout>
This error is because setSelection(i) doesn't select item i from the adapter for a AutoCompleteTextView, it attempts to move the cursor to position i in the current text, so if i is greater than the length of the text you get that error.
You can use setSelection(i) with a Spinner, but it has different behavior with an AutoCompleteTextView. To do the equivalent of setSelection in a AutoCompleteTextView, use this instead of the setSelection call:
binding.addressState.setText(statesArray[index], false)
The second argument (false) is necessary for it to operate like a spinner and keep the options around instead of applying a filter.
There is an older, but still useful, thread about this issue here too.

Application crashes sometimes on androidx.appcompat.widget.ContentFrameLayout.setDecorPadding() method

Sometimes, I get this crash while my app is opening:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.appcompat.widget.ContentFrameLayout.setDecorPadding(int, int, int, int)' on a null object reference
at androidx.appcompat.app.AppCompatDelegateImpl.applyFixedSizeWindow(AppCompatDelegateImpl.java:1026)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:820)
at androidx.appcompat.app.AppCompatDelegateImpl.onPostCreate(AppCompatDelegateImpl.java:527)
at androidx.appcompat.app.AppCompatActivity.onPostCreate(AppCompatActivity.java:127)
at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1381)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3499)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7814)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
As you can see, there's no reference to something in my code in the stack trace so for this reason I'm not able to figure out what the problem is. What could be the cause of this crash?.
In my case, I was getting this error in production when I load the first screen. I also use androidx and no Support Libraries. Some times this crash looks like:
Caused by java.lang.RuntimeException
Window couldn't find content container view ***.onCreate
Unfortunately, I still don't understand what exactly the error is but I found this post. I changed onCreate method to:
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
getWindow().getDecorView();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
}
Just added getWindow().getDecorView(); before super.onCreate(savedInstanceState); and it solved my problem.
Add as null check before calling this method
if (YourContentFrameLayout != null)
YourContentFrameLayout.setDecorPadding(intvalue,intvalue,intvalue,intvalue);

Android Picasso image loading app crash when scrolls the RecyclerView

I'm using the Retrofit to test and learn it as I have a project on it. While I use https://jsonplaceholder.typicode.com/photos for binding the photo into the recycle view. The issue is I can't scroll above 9 images; I mean whenever I scroll down to the 10th image, it is shown and then the app crashes.
img
2020-03-21 15:11:48.286 9426-9426/navneet.com.carsrecyclerview E/AndroidRuntime: FATAL EXCEPTION: main
Process: navneet.com.carsrecyclerview, PID: 9426
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:714)
at com.pkmmte.view.CircularImageView.refreshBitmapShader(CircularImageView.java:341)
at com.pkmmte.view.CircularImageView.invalidate(CircularImageView.java:262)
at android.widget.ImageView.setImageDrawable(ImageView.java:572)
at com.squareup.picasso.PicassoDrawable.setPlaceholder(PicassoDrawable.java:59)
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:728)
at navneet.com.carsrecyclerview.CarsAdapter.onBindViewHolder(CarsAdapter.java:58)
at navneet.com.carsrecyclerview.CarsAdapter.onBindViewHolder(CarsAdapter.java:24)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5752)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6019)
at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:286)
at android.support.v7.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:343)
at android.support.v7.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:359)
at android.support.v7.widget.GapWorker.prefetch(GapWorker.java:366)
at android.support.v7.widget.GapWorker.run(GapWorker.java:397)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
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:807)
the issue is similar to Android Picasso image loading app crash when scrolling RecyclerView but my point looks different.
Picasso.get().load(carsModels.get(i).getUrl()).noFade().resize(150,150).into(viewHolder.car_image, new Callback() {
#Override
public void onSuccess() {
}
#Override
public void onError(Exception e) {
Toast.makeText(context, "An error occurred", Toast.LENGTH_SHORT).show();
}
});
any help will be appriciated. thank you.
It seems to me that the problem may not be with Picasso. It could be with the third party CircularImageView that you are using. You can put a debug breakpoint at the android.graphics.Bitmap.createScaledBitmap(Bitmap.java:714) and see why the Bitmap object is null there. Then, you can go down the stack trace and figure out why it is null. That will give you a better idea of what you need to do to make sure your Bitmap object is instantiated before hitting that piece of code.
If you do find something, please update here so that I can edit this answer after better understanding the reason for your NullPointerException.
I think its better if you just load the image but the resizing happens on the ImageView end
Picasso.get().load(carsModels.get(i).getUrl()).noFade().into(viewHolder.car_image);
In your case, the car_image ImageView in layout XML should have:
android:layout_width="150dp"
android:layout_height="150dp"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
This ensures that the image you are loading inside is size 150x150 density pixels and making sure it doesn't stretch or look disoriented. It will start fitting in center if you have images that are not of equal aspect ratio.
I hope this helps!

Why does the application crash when trying to select text?

When I try to select text many times in the TextView, the application crashes with the error.
Does anyone know what could be the problem?
Error Stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: *** PID: 11481
java.lang.IndexOutOfBoundsException: setSpan (-1 ... -1) starts before 0
at android.text.SpannableStringInternal.checkRange(SpannableStringInternal.java:442)
at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:163)
at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:152)
at android.text.SpannableString.setSpan(SpannableString.java:46)
at android.text.Selection.setSelection(Selection.java:76)
at android.widget.Editor$SelectionModifierCursorController.resetDragAcceleratorState(Editor.java:5790)
at android.widget.Editor$SelectionModifierCursorController.onTouchEvent(Editor.java:5627)
at android.widget.Editor.onTouchEvent(Editor.java:1416)
at android.widget.TextView.onTouchEvent(TextView.java:9922)
at android.view.View.dispatchTouchEvent(View.java:11843)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2981)
....
2019-07-28 16:00:53.369 11481-11481/? E/AndroidRuntime: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4650)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4623)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7222)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7196)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7157)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7379)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:193)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:379)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:7383)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
Here is the markup for TextView:
<TextView
android:id="#+id/list_item_message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:gravity="center_vertical"
android:inputType="none"
android:linksClickable="true"
android:singleLine="false"
android:text="TextView"
android:lineSpacingExtra="3dp"
android:textIsSelectable="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
In the code I set the attribute: messageView.setMovementMethod (LinkMovementMethod.getInstance ());
I was able to reproduce only on android O and android N, in the following scenario:
Given a RecyclerView which presents a ViewHolder containing a TextView
That TextView as .setTextIsSelectable(true) and .setMovementMethod(LinkMovementMethod.getInstance())
Selecting a text from TextView and scrolling away from that particular view will cause crash. In particular, scrolling away while having presented that system overlay which offers "Copy", "Cut", "Paste", etc
So, my workaround (not a real solution but it will prevent crashes and it doesn't take users out of my app) was not allowing text selection on affected builds:
val selectable = when {
Build.VERSION.SDK_INT <= Build.VERSION_CODES.M -> true
Build.VERSION.SDK_INT >= Build.VERSION_CODES.P -> true
else -> false
}
textView.setTextIsSelectable(selectable)
textView.setMovementMethod(LinkMovementMethod.getInstance())
remove this
android:lineSpacingExtra="3dp"
Try to specify android:inputType="text". As well, you can add android:autoLink="all"
I think this is a problem in the Android Framework. Similar to the one described here:
java.lang.IndexOutOfBoundsException: getChars (7 ... 0) has end before start
Because and I have a similar error too. Thank you all.

Could not find a method onClick_Foo(View) - first time running on Android Lollipop

I have an app that is about a year old, is on the Play store in beta, has gone through dozens of revisions. All of a sudden I'm getting an error:
Could not find a method onClick_Foo(View) in the activity class
android.view.ContextThemeWrapper for onClick handler on view class
android.widget.Button with id 'Foo_Button'
I'm getting this error on every one of the 7 buttons defined in my XML. Since yesterday I've updating appcompat-v7 from 21.0.3 to 22.0.0 but also upgraded my testing device from KitKat to Lollipop for the first time.
I've double-checked spellings, capitalizations, none of the usual suspects explains this. Here's a sample of the relevant code. Let me know if you feel more would be helpful. (The activity has 915 lines of code and the xml 186, so don't ask for the whole thing). Testing on a Verizon Note 4 running Lollipop 5.0.1
activity_pick.xml:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:theme="#style/AppTheme"
tools:context="com.myapp.Pick"
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/Ratings_Button"
android:textSize="16dp"
android:text="#string/Pick_Ratings_Button"
android:onClick="onClick_Ratings"
android:background="#android:drawable/btn_default"/>
</LinearLayout>
</ScrollView>
Pick.java:
public class Pick_Restaurant extends ActionBarActivity {
public void onClick_Ratings (View v) {
Intent intent = new Intent(mContext, Ratings.class);
startActivityForResult(intent,RATINGS);
}
}
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 59
versionName "0.6.4"
}
...
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile files('libs/mobileservices-1.1.5.jar')
}
Full Error on Log:
04-08 17:06:40.578 3508-3508/com.myapp.debug E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.myapp.debug, PID: 3508
java.lang.IllegalStateException: Could not find a method onClick_Ratings(View) in the activity class android.view.ContextThemeWrapper for onClick handler on view class android.widget.Button with id 'Ratings_Button'
at android.view.View$1.onClick(View.java:4234)
at android.view.View.performClick(View.java:5191)
at android.view.View$PerformClick.run(View.java:20916)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5974)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: java.lang.NoSuchMethodException: onClick_Ratings [class android.view.View]
at java.lang.Class.getMethod(Class.java:665)
at android.view.View$1.onClick(View.java:4227)
            at android.view.View.performClick(View.java:5191)
            at android.view.View$PerformClick.run(View.java:20916)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:145)
            at android.app.ActivityThread.main(ActivityThread.java:5974)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
It looks like this is a new issue with Android 5.0.
From this anwer, removing the Theme from the layout xml fixed this issue for them.
So in your case, remove the theme from your layout:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!--android:theme="#style/AppTheme"--> <!-- Remove this -->
<!--................-->
</ScrollView>
And add the theme in the AndroidManifest.xml instead:
android:theme="#android:style/AppTheme"
I have just answered a similar question here
Basically, since Android 5.0 individual views can be themed.
To facilitate this, a ContextThemeWrapper is used to modify the underlying theme assigned to the Activity and assigned as the Context of the View. Since this Context is not your Activity anymore (the Activity has to be separate because it still has to return the original theme) the callbacks don't exist and you get the error you see.
If you don't really want to theme individual views the obvious solution is to not do so and theme the activity instead, as already suggested.
If you do indeed want to theme individual views, it appears that the android:onClick attribute cannot be used and you will have to fall back to manually assign an OnClickListener.
The question is, why did this work pre Lollipop? I can only speculate that because the functionality to theme individual views didn't exist, applying a theme attribute to a view would just change the default theme on the Activity as well.
Such things usually happens when you declare onClick in xml like you did:
android:onClick="onClick_Ratings"
Just make sure you are using this layout in that activity. Because the exception is clearly saying that your activity don't have the corresponding method which you did show you have:
public void onClick_Ratings (View v) {
Intent intent = new Intent(mContext, Ratings.class);
startActivityForResult(intent,RATINGS);
}
Also I guess you should declare the activity in your xml like:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".SendMessageActivity">
And actually log says:
Could not find a method onClick_Ratings(View) in the activity class
android.view.ContextThemeWrapper
there is something wrong since android.view.ContextThemeWrapper is not an Activity and not the activity from your xml com.myapp.Pick (I assume Pick is an activity and not the fragment). Maybe try to clean up the project, ivalidate caches and restart.
If nothing helps I suggest you to return back to previuos version of support lib you'd mentioned OR to set onClickListener in code instead of xml.
Removing android:theme works. But this is caused because using android:onclick in xml. If you use onClick in Java file, you can still use android:theme.
According to your code,
activity_pick.xml [Remove onclick here]
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/Ratings_Button"
android:textSize="16dp"
android:text="#string/Pick_Ratings_Button"
android:background="#android:drawable/btn_default" />
Go to your Java File, that is, pick.java in your case:
final Button button = (Button) findViewById(R.id.Ratings_Button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent activityChangeIntent = new Intent(CurrentActivity.this, SecondActivity.class);
SplashScreen.this.startActivity(activityChangeIntent);
}
});
Experienced the same error, app has stopped working, when material button was clicked programmatically helped me. Check it out :)

Categories

Resources