Android-dev.it Community

 
Annunci

:arrow: Benvenuto!, se non sei ancora un utente registrato: puoi registrati qui, oppure effettua il login
:arrow: Apri un forum sul tuo nuovo smartphone Android e collabora con noi! (dettagli)

www.agendadigitale.org
Image


Sponsor
It is currently Tue May 22, 2012 9:08 am

All times are UTC + 1 hour


 Topics   Replies   Views   Last post 
No new posts На интернет-витрине

by popowahgjfghjoiuyt on Sat May 19, 2012 2:25 pm in Amministrazione

0

12

Sat May 19, 2012 2:25 pm

popowahgjfghjoiuyt

No new posts Apri un forum sul tuo nuovo smartphone Android!

[ Go to page: 1, 2, 3 ]

by ReattileGar on Fri May 18, 2012 5:27 pm in Amministrazione

27

12514

Fri May 18, 2012 5:27 pm

ReattileGar

No new posts Новый: базы для хрумера - профессиональный софт для СЕО.

by Renatafe on Fri May 18, 2012 3:14 pm in Amministrazione

0

17

Fri May 18, 2012 3:14 pm

Renatafe

No new posts Pace is undoubtedly the vital affordable Jerseys Wholesale d

by barnettmmolive2012 on Wed May 16, 2012 7:36 am in Amministrazione

1

47

Wed May 16, 2012 7:36 am

barnettmmolive2012

No new posts Problema di compatibilità app

by deran on Tue May 15, 2012 10:44 am in Sviluppo e programmazione in Android

4

200

Tue May 15, 2012 10:44 am

deran




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Dove sbaglio? Problema con SetOnKeyListener
PostPosted: Mon Apr 18, 2011 12:23 pm 
Offline
User avatar

Joined: Wed Apr 06, 2011 2:46 pm
Posts: 7
Operatore: Vodafone
Punti Android: ?
Ciao a tutti questo esempio è preso dalla guida di ioprogrammo che sto studiando e provando.....sono alla parte dove si paciocca coi listener. Sto provando il tocco e quello x digitare i tasti. Ho fatto come dice nel libro copiando il codice anche x esser sicuro. C'è un .java e un main.xml x il layout.

In pratica c'è una edit a sfondo rosso dove se clicco o digito qualcosa vengon intercettati gli eventi e sotto in una casella di testo mi scrive cosa ho fatto(e anche nei log)......il tocco funziona ma coi tasti no......ho provato sia a pigiare dalla tastiera virtuale sia da quella del mio laptop, ma mi prende solo i tasti strani tipo delete, invio o cose così, quelli normali, tipo lettere e numeri nn li sente in pratica se vedete la foto l'ultimo tasto premuto è Z e invece di scrivermela me la mette sotto nell'angolo, poi quando premo invio me lo butta nella cosa rossa ma nn rileva l'evento..........rileva solo se premo subit ad esempio backspace.........metto codice e scrrenshot pls illuminatemi che sto sclerando :)

Code:
package it.ioprogrammo.eventdemo;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.View.OnKeyListener;
import android.widget.TextView;

public class EventDemoActivity extends Activity {

   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      View eventArea = (View) findViewById(R.id.eventArea);
      // Tocco
      eventArea.setOnTouchListener(new OnTouchListener() {
         public boolean onTouch(View view, MotionEvent event) {
            String action;
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
               action = "DOWN";
               break;
            case MotionEvent.ACTION_MOVE:
               action = "MOVE";
               break;
            case MotionEvent.ACTION_UP:
               action = "UP";
               break;
            default:
               action = "OTHER";
               break;
            }
            float x = event.getX();
            float y = event.getY();
            log("tocco: " + action + " su (" + x + "," + y + ")");
            return true;
         }
      });
      eventArea.setOnKeyListener(new OnKeyListener() {
         public boolean onKey(View view, int keyCode, KeyEvent event) {
            char c = event.getDisplayLabel();
            String action;
            switch (event.getAction()) {
            case KeyEvent.ACTION_DOWN:
               action = "DOWN";
               break;
            case KeyEvent.ACTION_UP:
               action = "UP";
               break;
            default:
               action = "OTHER";
               break;
            }
            log("Tasto: codice " + keyCode + " (" + c + "), azione " + action);
            return true;
         }
      });
   }
   
   private void log(String text) {
      // Logga
      Log.i("EVENT", text);
      // Mostra su schermo.
      TextView logArea = (TextView) findViewById(R.id.logArea);
      logArea.setText(text);
   }

}


Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center">
    <EditText android:id="@+id/eventArea"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:background="#990000"
       android:textColor="#FFFFFF"
       android:width="200px"
       android:height="200px" />
    <TextView android:id="@+id/logArea"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="Compi un evento sull'area rossa qui sopra" />
</LinearLayout>


[img]
***URLs are hidden from guests, please register and login to view the hyperlink***

Uploaded with ***URLs are hidden from guests, please register and login to view the hyperlink***
[/img]


Attachments:
prova.jpg
prova.jpg [ 176.18 KiB | Viewed 205 times ]
Top
 Profile  
 
 Post subject: Re: Dove sbaglio? Problema con SetOnKeyListener
PostPosted: Mon Apr 18, 2011 12:24 pm 
Offline
User avatar

Joined: Wed Apr 06, 2011 2:46 pm
Posts: 7
Operatore: Vodafone
Punti Android: ?
Ah già e poi cos'è quella barra cinese che mi apre sotto :)


Top
 Profile  
 
 Post subject: Re: Dove sbaglio? Problema con SetOnKeyListener
PostPosted: Mon Apr 18, 2011 1:40 pm 
Offline
User avatar

Joined: Wed Apr 06, 2011 2:46 pm
Posts: 7
Operatore: Vodafone
Punti Android: ?
Risolto, era solo un problema di impostazione della tastiere......ho tolto l'opzione japanese ime e altre opzioni a caso che nn ho ben capito quali aiuti dessero in writing e ora va :) scusate per il postone, se volete rimuovetelo pure :)


Top
 Profile  
 
 Post subject: Re: Dove sbaglio? Problema con SetOnKeyListener
PostPosted: Fri Apr 22, 2011 4:34 pm 
Offline
User avatar

Joined: Thu Dec 27, 2007 7:09 pm
Posts: 659
Cellulare Android: HTC Dream
Operatore: TIM
Punti Android: 758
ma come facevi ad avere la tastiera impostata in giapponese !?!? :)

_________________
***URLs are hidden from guests, please register and login to view the hyperlink***


Top
 Profile  
 
 Post subject: Re: Dove sbaglio? Problema con SetOnKeyListener
PostPosted: Fri Apr 22, 2011 4:44 pm 
Offline
User avatar

Joined: Wed Apr 06, 2011 2:46 pm
Posts: 7
Operatore: Vodafone
Punti Android: ?
Da quel che ho letto in giro è l'impostazione di default sulla 2.1 fatta girare sull'emulatore, c'è il japanise ime spuntato.............è pieno in giro di gente che chiedeva il perchè e come evitare di dover risettare ogni volta che si riavvia l'emulatore..........


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
phpBB SEO

All trademarks and logos used in this site are of properties of their respective owners.