Disable onscreen Keyboard

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Disable onscreen Keyboard

Postby glr » Fri Dec 25, 2009 10:02 am

Hey,

I looked around a lot but seems like there is no way to completly shut down onscreen Keyboard, I can however set my EditText editable to false but then I can't interact with it such as scroll it etc.

I tried in the manifest, I tried with the InputMethodManager aswell. No success.
Last edited by glr on Sat Dec 26, 2009 8:28 pm, edited 1 time in total.
glr
Freshman
Freshman
 
Posts: 9
Joined: Sat Nov 28, 2009 9:09 pm

Top

Postby glr » Fri Dec 25, 2009 7:43 pm

[...]
glr
Freshman
Freshman
 
Posts: 9
Joined: Sat Nov 28, 2009 9:09 pm

Postby glr » Sat Dec 26, 2009 9:56 pm

I solved it for now, it works but not so elegant.

EditText XML
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:focusable="false"
  2.  
  3. android:scrollHorizontally="true"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


You can not focus it, the cursor is not visible but you can scroll it horizontally. Which is what I wanted.

Second problem was, using a button to add a number made this EditText not to work properly.

If you use something like this ->

onCreate
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. numPad1.setOnClickListener(new View.OnClickListener() {
  2.  
  3.                        
  4.  
  5.                         @Override
  6.  
  7.                         public void onClick(View v) {
  8.  
  9.                                 currentEquationNumber += "1";
  10.  
  11.                                 updateDisplay();
  12.  
  13.                         }
  14.  
  15.                 });
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


updateDisplay
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private void updateDisplay() {          
  2.  
  3.         mainDisplay.setText(currentEquationNumber);
  4.  
  5.     }
  6.  
  7.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


First I must add, I am addings numbers from right to left. So when the numbers coming from right to left is reaching the left end the numbers stop to add from right to left but instead adding at the opposite.

This is because the cursor is tagging along the number to the left side.

However, if you use the keyboard the cursor stays in its place thus, adding number correctly, it will keep adding to the left no matter how many numbers you input.

So to solve this I had to mimic an actual input like this.

onCreate
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. numPad1.setOnClickListener(new View.OnClickListener() {
  2.  
  3.                        
  4.  
  5.                         @Override
  6.  
  7.                         public void onClick(View v) {
  8.  
  9.                                 keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_1);
  10.  
  11.                                 updateDisplay();
  12.  
  13.                         }
  14.  
  15.                 });
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


updateDisplay
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private void updateDisplay() {          
  2.  
  3.         mainDisplay.dispatchKeyEvent(keyEvent);
  4.  
  5.     }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
glr
Freshman
Freshman
 
Posts: 9
Joined: Sat Nov 28, 2009 9:09 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 2 guests