Reputation: 3543
I have a class MyTabsListener inside my main activity as follows:
Tabs Listener Class:
class MyTabsListener implements ActionBar.TabListener {
public Fragment frag = new Fragment();
public MyTabsListener(Fragment fragment) {
this.frag = fragment;
}
public void onTabReselected(Tab tab, FragmentTransaction ft) {
Toast.makeText(JSONActivity.appContext, "Reselected!", Toast.LENGTH_LONG).show();
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
ft.replace(R.id.fragment_container, frag);
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
ft.remove(frag);
}
}
I am using the support.v4 libraries when importing fragment, fragmenttransaction, etc..
However, eclipse tells me that: The type MyTabsListener must implement the inherited abstract method ActionBar.TabListener.onTabSelected(ActionBar.Tab, FragmentTransaction)
How can I fix this? If I change the class signature to:
public void onTabSelected(Tab tab, android.app.FragmentTransaction ft)
for example, then the method ft.replace
or ft.remove
will give me an error.
My imports are:
import android.os.Bundle;
import java.io.BufferedReader;
import java.io.IOException;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.content.Context;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.widget.Toast;
import android.os.AsyncTask;
Any ideas?
Thanks in advance!
Upvotes: 0
Views: 1172
Reputation: 481
I don't think you can mix the support library (Fragment*) with the standard library (ActionBar*). Google hasn't released the compatibility library for ActionBar as of yet so consider using ActionBarSherlock.
Upvotes: 1