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 to match "intent()" but nothing change. it's still error.
package com.spamcity;
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;
public class postingActivity extends Fragment {
private ImageButton infrastructure;
private ImageButton trafficjam;
private ImageButton others;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View V = inflater.inflate(R.layout.posting_activity, container, false);
setupVariables();
addListenerOnButton();
return V;
}
public void addListenerOnButton() {
Intent intent = new Intent(getBaseContext(), writeActivity.class); // error
// want me to create method getBaseContext()
// infrastructure
infrastructure.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
startActivity(intent); //error
finish();
}
});
// traffic jam
trafficjam.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
startActivity(new Intent(postingActivity.this, writeActivity.class)); // error
finish();
}
});
// others
others.setOnClickListener(new OnClickListener() {
@Override
public void onCzlick(View arg0) {
startActivity(new Intent(postingActivity.this, writeActivity.class)); // error
finish();
}
});
}
protected void finish() {
// TODO Auto-generated method stub
// they require this method to be exist
// but I dont know what should I write here
}
private void setupVariables(){
infrastructure = (ImageButton) findViewById(R.id.btnInfra);
trafficjam = (ImageButton) findViewById(R.id.btnTrafJam);
others = (ImageButton) findViewById(R.id.btnOther);
}
}
I don't understand what went wrong here. thanks for trying to help.