i am facing A problem ...i Created A Item on Action bar ..When I click On That Item My Item Click Button Is not Responding ..For Printing I created Toast ..To Check Resopnse But Toast Is NOt Displaying
Here Is updated fragment class ..
public class Welcome extends SherlockFragment {
private ProgressDialog pDialog;
Button editprofile;
JSONParser jsonParser = new JSONParser();
ImageView i;
Editor editor;
SharedPreferences sharedPreferences;
ImageView frm;
ImageLoader imageloader;
String image_url;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.welcome, container, false);
final UserModel user = (UserModel) getActivity().getIntent().getSerializableExtra("User");
frm=(ImageView)rootView.findViewById(R.id.image_frm);
// Button editprofile = (Button)rootView.findViewById(R.id.btn_edit);
//ImageView image = (ImageView)rootView. findViewById(R.id.imageView1);
TextView userfullname = (TextView)rootView. findViewById(R.id.userfullname);
TextView tv_tomeet = (TextView)rootView. findViewById(R.id.tomeet);
TextView tv_intrseted = (TextView) rootView.findViewById(R.id.intsdin);
int loader = R.drawable.loader;
String UserfullName = user.getUser_Full_Name();
String Tomeet=user.getTo_Meet();
String Age = user.getUser_Age();
String Gender = user.getGender();
String IntrestedIn = user.getIntrest_In();
Bundle bundle = this.getArguments();
String image_url=user.getUser_Image();
userfullname.setText(UserfullName);
tv_tomeet.setText(Tomeet);
//image loader
setHasOptionsMenu(true);
//imageloader=new ImageLoader();
//tv_gender.setText(Gender);
ImageView iv = (ImageView)rootView.findViewById(R.id.imageView1);
Picasso.with(getActivity())
.load(image_url).transform(new RoundedImageView()).into(iv);
frm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String image_url=user.getUser_Image();
Bundle bundle = new Bundle();
bundle.putString("UserImage", image_url);
}
});
// ImageLoader class instance
//ImageLoader imgLoader = new ImageLoader(getActivity());
// whenever you want to load an image from url
// call DisplayImage function
// url - image url to load
// loader - loader image, will be displayed before getting image
// image - ImageView
/* imgLoader.DisplayImage(image_url, Welcome.this, image);*/
return rootView;
}
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu,MenuInflater inflater)
{
inflater.inflate(R.menu.action_bar_menu, menu);
//super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
switch (item.getItemId()) {
case R.id.action_search:
logout();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
///Logout User And Clear Sharedpref
public void logout(){
Toast.makeText(getActivity(), "hi Logout", Toast.LENGTH_LONG).show();
sharedPreferences = getActivity().getSharedPreferences(MainActivity.MyLOGINDATA
,0);
editor = sharedPreferences.edit();
editor.clear();
editor.commit();
Intent l=new Intent(getActivity(),MainActivity.class);
startActivity(l);
getActivity().finish();
}
}
here Is Menu Item
<item
android:id="@+id/action_search"
android:icon="@drawable/setting_iconn"
android:title="Setting"
android:showAsAction="always"
/>
I really Dont Understand What I m Doing Wrong? please help Me
Edit
I created in fragment class
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
onclick Not Working Stil