Note that there are some explanatory texts on larger screens.

plurals
  1. POButton visibility/invisibility issue.
    text
    copied!<p>I am working android application that required login, Now I want After successfully login into my application, login button should be invisible and logout button should be visible, but getting errors.</p> <p>I am using this function:</p> <pre><code>login.setVisibility(View.GONE); &amp; logout.setVisibility(View.VISIBLE); </code></pre> <p>Eclipse give me error in logcat like: </p> <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rahul.cheerfoolz/com.rahul.cheerfoolz.CheerfoolznativeActivity}: java.lang.NullPointerException. </code></pre> <p>Main.class</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); session = new SessionID(); Button login = (Button) findViewById(R.id.home_btn_feature_login); Button logout = (Button) findViewById(R.id.home_btn_feature_logout); int userID = SessionID.getUserID(); System.out.println("value of the userID into the main page:====&gt;"+userID); // when user login then here I got the userID value if ((userID) &gt; 0) { login.setVisibility(View.GONE); //when Execute this give me error logout.setVisibility(View.VISIBLE); //when Execute this give me error } else { login.setVisibility(View.VISIBLE); //when Execute this give me error logout.setVisibility(View.GONE); //when Execute this give me error } setContentView(R.layout.main); setHeader_home(""); } </code></pre> <p>Main.xml</p> <pre><code> &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="2" android:orientation="horizontal" &gt; &lt;!-- Here Login Button --&gt; &lt;Button android:id="@+id/home_btn_feature_login" style="@style/HomeButton" android:drawableTop="@drawable/login_button" android:onClick="onClickFeature" android:text="@string/title_feature_login" /&gt; &lt;!-- Here Logout Button --&gt; &lt;Button android:id="@+id/home_btn_feature_logout" style="@style/HomeButton" android:drawableTop="@drawable/logout_button" android:onClick="onClickFeature" android:text="@string/title_feature_logout" /&gt; &lt;Button android:id="@+id/home_btn_feature2" style="@style/HomeButton" android:drawableTop="@drawable/register_button" android:onClick="onClickFeature" android:text="@string/title_feature_register" /&gt; &lt;/LinearLayout&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload