Note that there are some explanatory texts on larger screens.

plurals
  1. POLayout visibility changing is possible while i am in another layout?
    primarykey
    data
    text
    <p>Here I create four <strong>xml</strong> files <code>main.xml</code>,<code>test1.xml</code>,<code>test2.xml</code>,<code>test3.xml</code>.</p> <p>They are accessed in <code>spinner</code> but I received an exception. I am giving <strong>logcat</strong> also.</p> <p>Please help me.</p> <pre><code>String[] lan = { "test1", "test2", "test3" }; Spinner spn = (Spinner) findViewById(R.id.spinner1); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_dropdown_item, lan); spn.setAdapter(adapter); spn.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int pos, long id) { if (pos == 0) { findViewById(R.layout.test1).setVisibility(View.VISIBLE); } else if (pos == 1) { findViewById(R.layout.test2).setVisibility(View.VISIBLE); } else if (pos == 2) { findViewById(R.layout.test3).setVisibility(View.VISIBLE); } } @Override public void onNothingSelected(AdapterView&lt;?&gt; arg0) { } }); </code></pre> <p>Logcat:</p> <pre><code>07-11 18:09:39.480: E/AndroidRuntime(21200): FATAL EXCEPTION: main 07-11 18:09:39.480: E/AndroidRuntime(21200): java.lang.NullPointerException 07-11 18:09:39.480: E/AndroidRuntime(21200): at com.venky.innverlayoutchangevisibility.MainActivity$1.onItemSelected(MainActivity.java:30) 07-11 18:09:39.480: E/AndroidRuntime(21200): at android.widget.AdapterView.fireOnSelected(AdapterView.java:871) 07-11 18:09:39.480: E/AndroidRuntime(21200): at android.widget.AdapterView.access$200(AdapterView.java:42) 07-11 18:09:39.480: E/AndroidRuntime(21200): at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:837) 07-11 18:09:39.480: E/AndroidRuntime(21200): at android.os.Handler.handleCallback(Handler.java:587) 07-11 18:09:39.480: E/AndroidRuntime(21200): at android.os.Handler.dispatchMessage(Handler.java:92) 07-11 18:09:39.480: E/AndroidRuntime(21200): at android.os.Looper.loop(Looper.java:130) 07-11 18:09:39.480: E/AndroidRuntime(21200): at android.app.ActivityThread.main(ActivityThread.java:3691) 07-11 18:09:39.480: E/AndroidRuntime(21200): at java.lang.reflect.Method.invokeNative(Native Method) 07-11 18:09:39.480: E/AndroidRuntime(21200): at java.lang.reflect.Method.invoke(Method.java:507) 07-11 18:09:39.480: E/AndroidRuntime(21200): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907) 07-11 18:09:39.480: E/AndroidRuntime(21200): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) 07-11 18:09:39.480: E/AndroidRuntime(21200): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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