package com.example.dh.qrock;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class mainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button goManageList = (Button)findViewById(R.id.goManageList);
goManageList.setOnClickListener(
new Button.OnClickListener()
{
public void onClick(View v)
{
Intent myIntent = new Intent(v.getContext(), managelistActivity.class);
startActivity(myIntent);
finish();
overridePendingTransition(R.xml.madefadein, R.xml.splashfadeout);
}
}
);
}
}
when changing activity, the application has stopped.
I use fade in and fade out.
How to fix that?
If you need another code, please comment here.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dh.qrock, PID: 4356
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dh.qrock/com.example.dh.qrock.managelistActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.example.dh.qrock.managelistActivity.onCreate(managelistActivity.java:19)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
here is the log.
It occurs NullPointException in button.
how to fix the NullPointException?
I changed Button.setOnclicklistener to View.onclickListener, But It doesn't work.
Check the id of your Button goManageList if it exists in your R.layout.activity_main
Because you have this error
Attempt to invoke virtual method 'void
android.widget.Button.setOnClickListener(android.view.View$OnClickListener)'
on a null object reference
It means that you are setting a setOnClickListener to a null object
this because
overridePendingTransition(R.xml.madefadein, R.xml.splashfadeout);
The problem is you are using the context of the button in the intent like this:
Intent myIntent = new Intent(v.getContext(), managelistActivity.class);
Give the context of the current activity like this:
Intent myIntent = new Intent(mainActivity.this, managelistActivity.class);
change Button.OnClickListener to View.OnClickListener
goManageList.setOnClickListener(
new Button.OnClickListener()
to
goManageList.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
Related
I am a beginner at the android studio I was trying to build a timer app in android studio and it was always crashing i don't understand why can anyone help
here's my code
package com.example.timers;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView hello;
CountDownTimer countDownTimer;
public MainActivity() {
hello = (TextView) findViewById(R.id.textView);
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
countDownTimer = new CountDownTimer(10000,1000) {
#Override
public void onTick(long l) {
hello.setText(String.valueOf(l/1000));
}
#Override
public void onFinish() {
}
}.start();
}
}
and here's what it shows in the logcat shows
2020-09-20 15:09:50.663 13306-13306/com.example.timers E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.timers, PID: 13306
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.timers/com.example.timers.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
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)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:152)
at android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:157)
at android.content.Context.obtainStyledAttributes(Context.java:655)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:839)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:806)
at androidx.appcompat.app.AppCompatDelegateImpl.findViewById(AppCompatDelegateImpl.java:630)
at androidx.appcompat.app.AppCompatActivity.findViewById(AppCompatActivity.java:223)
at com.example.timers.MainActivity.<init>(MainActivity.java:15)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
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)
please someone help me with this ive been trying this since very long but still did'nt find a solution it works for others on udemy but isnt working for my ive even seen youtube video but it still doesnt work
Remove
public MainActivity() {
hello = (TextView) findViewById(R.id.textView);
}
and initialize hello object in onCreate method
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
hello = (TextView) findViewById(R.id.textView);
countDownTimer = new CountDownTimer(10000,1000) {
#Override
public void onTick(long l) {
hello.setText(String.valueOf(l/1000));
}
#Override
public void onFinish() {
}
}.start();
}
I am new to Android in-app purchases. I have followed the official documentation and I can't go beyond building the BillingClient as app crashes when it tries to build the BillingClient. Any help or any reference to a android in-app purchases in Java is much appreciated. My MainActivity.java codes is as follows:
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.BillingClientStateListener;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.PurchasesUpdatedListener;
import java.util.List;
public class MainActivity extends AppCompatActivity{
private PurchasesUpdatedListener purchaseUpdateListener = new PurchasesUpdatedListener() {
#Override
public void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
// To be implemented in a later section.
}
};
private BillingClient billingClient = BillingClient.newBuilder(MainActivity.this)
.setListener(purchaseUpdateListener)
.enablePendingPurchases()
.build();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Crash Log is as follows:
2020-07-07 01:19:40.667 27956-27956/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.js.bs, PID: 27956
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.js.bs/com.js.bs.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3272)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3500)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2049)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:122)
at com.android.billingclient.api.BillingClientImpl.initialize(com.android.billingclient:billing##3.0.0:26)
at com.android.billingclient.api.BillingClientImpl.<init>(com.android.billingclient:billing##3.0.0:13)
at com.android.billingclient.api.BillingClientImpl.<init>(com.android.billingclient:billing##3.0.0:1)
at com.android.billingclient.api.BillingClient$Builder.build(com.android.billingclient:billing##3.0.0:14)
at com.js.bs.MainActivity.<init>(MainActivity.java:31)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:41)
at android.app.Instrumentation.newActivity(Instrumentation.java:1253)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3260)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3500)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2049)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
2020-07-07 01:19:41.044 27956-27956/? I/Process: Sending signal. PID: 27956 SIG: 9
Please change the billingClient object creation as below. While creating this object from outside the context may be null, so crashing. Move the object creation to onCreate() method of the activity.
private BillingClient billingClient;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
billingClient = BillingClient.newBuilder(this)
.setListener(purchaseUpdateListener)
.enablePendingPurchases()
.build();
}
I inherited a project, trying to understand and solve an old bug.
When I start an activity and let it sit for a bit (sometimes it's almost immediate), but it appears to go into a pause state or something and attempts to reload the activity and gets an error.
"Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String ... ' on a null object reference"
I found that when I add this to my activity:
#Override
public void onSaveInstanceState(Bundle savedInstanceState)
{
//super.onSaveInstanceState(savedInstanceState);
}
It appears to work perfectly.
However, when I uncomment the line above to super.onSaveInstanceState(savedInstanceState);, I get the error again.
My activity is extending the ActionBarActivity, if that is helpful.
Any help would be appreciated. Thank you!
Related Code:
#Override
protected void prepareLayout() {
textMessage = (TextView) findViewById(R.id.textMessage);
textNotes = (EditText) findViewById(R.id.textNotes);
textMessage.setText(getOneOfMyItems().getText());
// ... the above line is where the problem error is thrown.
}
Stack Trace:
Process: com.myproj.myproj, PID: 9272
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myproj.myproj/com.myproj.activities.MyActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.myproj.data.MyItems.getText()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3288)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3384)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5433)
at android.app.ActivityThread.access$1200(ActivityThread.java:226)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1810)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7270)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.myproj.data.MyItems.getText()' on a null object reference
at com.myproj.xyz.MyFragment.prepareLayout(MyFragment.java:44)
at com.myproj.fragments.BaseFragment.prepareAndSetView(BaseFragment.java:49)
at at com.myproj.xyz.BaseMyFragment.onCreateView(BaseMyFragment.java:21)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1268)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2143)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2089)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1129)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1268)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2143)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:615)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1266)
at android.app.Activity.performStart(Activity.java:6943)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3384)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5433)
at android.app.ActivityThread.access$1200(ActivityThread.java:226)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1810)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7270)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I am trying to integrate following SDK into a Xamarin Android App: https://github.com/developermypos/myPOS-SDK-Android
If I try to get the POSHandler Instance I get following exception:
Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName():
Unhandled Exception:
Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
--- End of managed Java.Lang.NullPointerException stack trace ---
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
at android.widget.Toast.<init>(Toast.java:103)
at android.widget.Toast.makeText(Toast.java:256)
at eu.leupau.icardpossdk.POSHandler.setDefaultInfoListener(POSHandler.java:149)
at eu.leupau.icardpossdk.POSHandler.<init>(POSHandler.java:145)
at eu.leupau.icardpossdk.POSHandler.getInstance(POSHandler.java:127)
at md5b2d2fb169710eaa19162eaff312d3328.MainActivity.n_onCreate(Native Method)
at md5b2d2fb169710eaa19162eaff312d3328.MainActivity.onCreate(MainActivity.java:29)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
In the POSHandler.java file I found following function, which obviously causes the issue:
void setDefaultInfoListener()
{
final Toast toast = Toast.makeText(SDKApplication.getAppContext(), "", 1); // <-- **Exception**!
TextView textView = (TextView)toast.getView().findViewById(16908299);
if (textView != null) {
textView.setGravity(17);
}
My code:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
private POSHandler _myPosHandler;
protected override void OnCreate ( Bundle bundle ) {
POSHandler.SetLanguage(Language.English);
POSHandler.SetDefaultReceiptConfig(POSHandler.ReceiptPrintOnlyMerchantCopy);
POSHandler.SetCurrency(Currency.Chf);
POSHandler.ConnectionType = ConnectionType.Bluetooth;
_myPosHandler = POSHandler.Instance; // <-- **EXCEPTION**
...
Any ideas what might be the issue?
I am trying to make a PopupWindow to explain my app, however I am having a lot of difficulty for a seemingly simple thing. I tried various youtube videos and looked at almost all the similar posts on here about it, but I haven't had any luck yet. If someone can please point out my flaw, that'd be great.
My end goal is for the PopupWindow to appear with the on create method, but I included a Button to start it for now because all the tutorials included one.
protected void onCreate(Bundle savedInstanceState) {
//BUILDING THE POP UP WINDOW ON CLICK OF HELP BUTTON
help=(Button)findViewById(R.id.help);
help.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
layoutInflater=(LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View customView= layoutInflater.inflate(R.layout.activity_instructions, null);
popUpWindow=new PopupWindow(
customView,
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT
);
myButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
popUpWindow.dismiss();
}
});
}
});
Any help would be greatly appreciated. If I need to include any more information, please do ask. I am new to android and this is my first big Application so keeping my hopes up.
Thanks
The link to my log
07-30 23:32:07.062 9273-9273/my.myCompany.vinay.diversityformulaapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.myCompany.vinay.diversityformulaapplication, PID: 9273
java.lang.RuntimeException: Unable to start activity ComponentInfo{my.myCompany.vinay.diversityformulaapplication/my.myCompany.vinay.diversityformulaapplication.EntryScreen}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at my.myCompany.vinay.diversityformulaapplication.EntryScreen.onCreate(EntryScreen.java:37)
at android.app.Activity.performCreate(Activity.java:6912)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
myButton is null here. you are missing this
myButton = (Button)customView.findViewById(R.id.myButtonId);