Android: Intent Asks Remove Argument & Getbasecontext() Ask To Create Its Method
I'm trying to make 3 tabs with fragments from TabHost with Fragments and FragmentActivity and find problems with my intent in 3rd tab. I tried this method Android Remove arguments
Solution 1:
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.widget.ImageButton;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
publicclasspostingActivityextendsFragment {
privateImageButton infrastructure;
privateImageButton trafficjam;
privateImageButton others;
@OverridepublicViewonCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragmentView V = inflater.inflate(R.layout.posting_activity, container, false);
infrastructure = (ImageButton) V.findViewById(R.id.btnInfra);
trafficjam = (ImageButton) V.findViewById(R.id.btnTrafJam);
others = (ImageButton) V.findViewById(R.id.btnOther);
addListenerOnButton();
return V;
}
publicvoidaddListenerOnButton() {
final Intent intent = newIntent(getActivity(), writeActivity.class); // error// want me to create method getBaseContext()// infrastructure
infrastructure.setOnClickListener(newOnClickListener() {
@OverridepublicvoidonClick(View arg0) {
startActivity(intent); //errorgetActivity().finish();
}
});
// traffic jam
trafficjam.setOnClickListener(newOnClickListener() {
@OverridepublicvoidonClick(View arg0) {
startActivity(newIntent(getActivity(), writeActivity.class)); // errorgetActivity().finish();
}
});
// others
others.setOnClickListener(newOnClickListener() {
@OverridepublicvoidonClick(View arg0) {
startActivity(newIntent(getActivity(), writeActivity.class)); // errorgetActivity().finish();
}
});
}
}
this works properly try this
Solution 2:
Try getActivity() Rather than getBaseContext()
Post a Comment for "Android: Intent Asks Remove Argument & Getbasecontext() Ask To Create Its Method"