Android

Android


4.INTRODUCCIÓN DE TEXTOS

Página 47 de 286

u

e

d

e

h

a

c

e

r

s

e

g

ú

n

c

o

n

v

e

n

g

a

.

 

 

p

u

b

l

i

c

c

l

a

s

s

I

n

p

u

t

T

e

x

t

e

x

t

e

n

d

s

A

c

t

i

v

i

t

y

i

m

p

l

e

m

e

n

t

s

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

O

n

K

e

y

L

i

s

t

e

n

e

r

{

E

d

i

t

T

e

x

t

e

d

i

t

t

e

x

t

;

T

e

x

t

V

i

e

w

t

v

;

 

 

 

 

@

O

v

e

r

r

i

d

e

 

 

 

 

p

u

b

l

i

c

v

o

i

d

o

n

C

r

e

a

t

e

(

B

u

n

d

l

e

s

a

v

e

d

I

n

s

t

a

n

c

e

S

t

a

t

e

)

{

 

 

 

 

 

 

 

 

s

u

p

e

r

.

o

n

C

r

e

a

t

e

(

s

a

v

e

d

I

n

s

t

a

n

c

e

S

t

a

t

e

)

;

 

 

 

 

 

 

 

 

s

e

t

C

o

n

t

e

n

t

V

i

e

w

(

R

.

l

a

y

o

u

t

.

m

a

i

n

)

;

 

 

 

 

 

 

 

 

t

v

=

(

T

e

x

t

V

i

e

w

)

f

i

n

d

V

i

e

w

B

y

I

d

(

R

.

i

d

.

t

e

x

t

2

)

;

 

 

 

 

 

 

 

 

e

d

i

t

t

e

x

t

=

(

E

d

i

t

T

e

x

t

)

f

i

n

d

V

i

e

w

B

y

I

d

(

R

.

i

d

.

e

d

i

t

T

e

x

t

1

)

;

 

 

 

 

 

 

 

 

e

d

i

t

t

e

x

t

.

s

e

t

O

n

K

e

y

L

i

s

t

e

n

e

r

(

t

h

i

s

)

;

 

 

 

 

}

 

 

 

 

p

u

b

l

i

c

b

o

o

l

e

a

n

o

n

K

e

y

(

V

i

e

w

v

,

i

n

t

k

e

y

C

o

d

e

,

K

e

y

E

v

e

n

t

e

v

e

n

t

)

 

 

 

 

 

 

 

 

{

 

 

 

 

 

 

 

 

 

/

/

s

i

s

e

p

u

l

s

a

l

a

t

e

c

l

a

e

n

t

e

r

 

 

 

 

 

 

 

 

i

f

(

(

e

v

e

n

t

.

g

e

t

A

c

t

i

o

n

(

)

=

=

K

e

y

E

v

e

n

t

.

A

C

T

I

O

N

_

D

O

W

N

)

&

&

 

 

 

 

 

 

 

 

 

 

 

 

(

k

e

y

C

o

d

e

=

=

K

e

y

E

v

e

n

t

.

K

E

Y

C

O

D

E

_

E

N

T

E

R

)

)

{

 

 

 

 

 

 

 

 

 

 

T

o

a

s

t

.

m

a

k

e

T

e

x

t

(

I

n

p

u

t

T

e

x

t

.

t

h

i

s

,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

e

d

i

t

t

e

x

t

.

g

e

t

T

e

x

t

(

)

,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

T

o

a

s

t

.

L

E

N

G

T

H

_

S

H

O

R

T

)

.

s

h

o

w

(

)

;

 

 

 

 

 

 

 

 

 

 

t

v

.

s

e

t

T

e

x

t

(

"

B

i

e

n

v

e

n

i

d

o

"

+

e

d

i

t

t

e

x

t

.

g

e

t

T

e

x

t

(

)

)

;

 

 

 

 

 

 

 

 

 

 

r

e

t

u

r

n

t

r

u

e

;

 

 

 

 

 

 

 

 

}

 

 

 

 

 

 

 

 

r

e

t

u

r

n

f

a

l

s

e

;

}

 

}

E

l

p

r

e

s

e

n

t

e

m

é

t

o

d

o

n

o

s

p

e

r

m

i

t

e

e

n

t

e

n

d

e

r

m

á

s

f

á

c

i

l

m

e

n

t

e

e

l

c

ó

d

i

g

o

,

p

u

e

s

n

o

s

a

h

o

r

r

a

m

o

s

d

e

f

i

n

i

r

u

n

a

c

l

a

s

e

y

u

n

o

b

j

e

t

o

i

n

t

e

r

n

o

s

,

l

o

q

u

e

d

i

f

i

c

u

l

t

a

l

a

l

e

c

t

u

r

a

l

i

n

e

a

l

Ir a la siguiente página

Report Page