2013-12-07 3 views
0

У меня есть ListView с простым адаптером, если я щелкните элемент ListView элемента управления ListView Шоуда скрыть и другой макет Шоуда показатьКак скрыть представление списка и показать другой макет в андроиде?

Я судимый так для
ListView Код

final String[] questions = new String[] { 
     "1. What was banned in 393 A.D. as it was considered an unholy ritual by the Romans?", 
     "2. The musical instrument ‘veena’ is made from the wood of which tree?", 
     "3. The movie Jurassic Park was based on a novel of the same name. Can you name the author?", 
     "4. Which famous personality was assassinated on 31st October 1984 by Satwant Singh and Beant Singh?", 
     "5. Who owns the newspaper Saakshi and used it to campaign in the media?", 
     "6. The filament of a common light bulb is generally made from which material?", 
     "7. Who was the last Tsar (king) of Russia who along with his entire family was murdered in the Russian revolution in 1917?", 
     "8. Who in Indian sports is known as the Flying Sikh?", 
     "9. In internet terminology we often come across the term URL. What does URL stand for?", 
    "10. In world of children literature, who is the famous sister of Anastasia and Drizella?" }; 

    for (int i = 0; i < questions.length; i++) { 

     HashMap<String, String> temp = new HashMap<String, String>(); 
     temp.put("question", questions[i]); 
     TotalQuestion.add(temp); 
    } 
    SimpleAdapter sa = new SimpleAdapter(getApplicationContext(), 
         TotalQuestion, R.layout.activity_question, new String[] { 
         "question" }, new int[] { R.id.text_question }); 
    lv.setAdapter(sa);` 

И я пытаюсь скрыть ListView в списке следует onItemclick кодекса, чтобы скрыть ListView является

View myView = findViewById(R.id.linearLayout1);//linearLayout1 Contains listview textbox 
    ViewGroup parent = (ViewGroup) myView.getParent(); 
    parent.removeView(myView); 

    LinearLayout hiddenLayout = (LinearLayout) findViewById(R.id.hiddenLayout); 
      if (hiddenLayout == null) { 
       // Inflate the Hidden Layout Information View 
       LinearLayout myLayout = (LinearLayout) findViewById(R.id.linearLayout2); 
       View hiddenInfo = getLayoutInflater().inflate(R.layout.hidden, myLayout, false); 
       myLayout.addView(hiddenInfo); 
      } 
+0

Почему вы хотите скрыть 'listView'? почему бы не открыть другой макет за один шаг? –

+0

Вопрос в listview, и если я нажму на список, страница ответа должна отображаться, так что только мне это нужно – John

ответ

0

, если вы хотите изменить макет, который вы можете вызвать setContentView(); снова в любом месте, где вы хотите (в вашем приложении это должно быть вызвано выбором элемента списка), но в ваших сценариях я считаю, что вам нужно положение вашего списка в другом действии, поэтому создайте другой класс и вызовите класс с намерением и передайте ваши данные с этим.

Смежные вопросы