0

my actvity has 2 views. That means I am using 2 .xml files within one java class.

       first_view.xml
       second_view.xml

First view (first_view.xml) contains one EditText and one save button. when I click the EditText, the virtual keyboard is displayed on the view, and I can enter a value there. In onClick() of save button, i want to display the second view. (that means the details of the enterd value).

So i use 'setContentView(R.layout.second_view);' on the onClick() of save button.

My problem is the second view is coming properly, but the virtual keyboard is still displayed on the view. I use LinearLayout in second view, and set its height and width as "fill_parent". but I can't solve the problem.

I hope you understand the question.. Please help me... Thank you...

Miya
  • 173
  • 3
  • 8
  • 16

2 Answers2

1

I think you are not really supposed to call setContentView() to change the UI after it has been loaded & the activity created. If you intend to change the UI, consider a LayoutInflater: http://developer.android.com/reference/android/view/LayoutInflater.html

How about you add another Activity, and simple call it? This will save you a lot of trouble in the long term, like freeing up memory and so on. If you intend to replace the current activity with the new one, consider a call to finish() before you call the new one.

Sebastian Roth
  • 10,454
  • 13
  • 56
  • 103
0

@Miya I suggest you to have a look @ this thread Close/hide the Android Soft Keyboard & use this

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

& you are done!

Community
  • 1
  • 1
100rabh
  • 6,028
  • 5
  • 24
  • 40