在行::
中ActionBar actionBar = ((ActionBarActivity)getActivity()).getSupportActionBar();
我收到错误::
的 ActionBarActivity cannot be resolved to a type
public class ActLogin extends ActionBarActivity {
String className;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_login);
//set
//Set the color for Actionbar
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.windhya_actionbar_color)));
//Hide Appicon
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setIcon(android.R.color.transparent);
//First fragment should be mounted on oncreate of main activity
if (savedInstanceState == null) {
Fragment newFragment = FrgLogin.newInstance();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, newFragment).addToBackStack(FrgLogin.class.getSimpleName()).commit();
}
}
.....
import java.io.InputStream;
import org.json.JSONException;
import org.json.JSONObject;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import com.windhyaworks.R;
import com.windhyaworks.activities.ActMain;
import com.windhyaworks.utils.CommonFunctions;
import com.windhyaworks.utils.DlgUniversalError;
import com.windhyaworks.utils.JSONParser;
public class FrgLogin extends Fragment{
FragmentTransaction ft = null;
Button btnLoginId;
EditText edtPhnoId;
SharedPreferences sharedpreferences;
private static String errMsg=null;
private static boolean isErr=false;
boolean isVendor=false;
String phoneNumber="NoValue";
String authCode="NoValue";
String otpCode="NoValue";
String loginMsg,loginStatus;
private ProgressDialog prg;
boolean isServerResponsive=false;
public static FrgLogin newInstance(){
Log.d(FrgLogin.class.getSimpleName(), "newInstance");
FrgLogin fragment = new FrgLogin();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
//Make sure the keyboard only pops up when a user clicks into an EditText
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
//Hide icon from navigation drawer.
//getActivity().getActionBar().setDisplayHomeAsUpEnabled(false);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.frg_login, container, false);
btnLoginId=(Button) view.findViewById(R.id.btnLoginId);
edtPhnoId=(EditText) view.findViewById(R.id.edtPhnoId);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//getActivity().getSupportActionBar().setTitle("HIIIIIIIIIIIIIIIIIIIIIIIIi");
ActionBar actionBar = ((ActionBarActivity)getActivity()).getSupportActionBar();
}
.....
答案 0 :(得分:0)
您需要从android.support.v7.app.ActionBarActivity
导入它。如包名称所示,您需要support-v7包。