0

In my application i used tab widget for home activity. it's include 4 tabs. unregistered user can access only two tabs. for access other two(favorite and offers) user should register.

I used Android User Session Management using SharedPreferences for the session management.

when i click offers tab it load login activity,But when i tried to go back it display the offers activity.

I want to hide the offers and favorite tabs contents when user not log.

This is the Offers Activity

public class Offers extends Activity {

    SessionManager session;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.offers_layout);


        session = new SessionManager(getApplicationContext());

        session.checkLogin();

        HashMap<String, String> user = session.getUserDetails();

        String name = user.get(SessionManager.KEY_NAME);

        String email = user.get(SessionManager.KEY_EMAIL);

        Toast.makeText(getApplicationContext(), email, Toast.LENGTH_LONG).show();
        }

      //Content

}

Other classes are same as the link mentioned above.

I want to hide offers content when user not login. Can any one help me?

anuruddhika
  • 1,549
  • 8
  • 26
  • 40

1 Answers1

1

You have to do in on resume of the activity follow the steps

  1. on resume check for which tab has to enabled or disabled.

  2. then use following lonk to enable or disable tabs link

Community
  • 1
  • 1
Sush
  • 3,864
  • 2
  • 17
  • 35
  • thanks for your answer.now i disable the tabs when user not login.do you know how to add alert when user click disable tab? alert saying "please login" like. – anuruddhika Jan 02 '14 at 05:39
  • then u dont disable that, have check for it in onclick listener. – Sush Jan 02 '14 at 05:43
  • I did not use onclicklistener. I override onTabChanged() method.Do you have any idea,how to do that? – anuruddhika Jan 02 '14 at 06:09