Setting no. of chars to be displayed in EditText using API

Put your problem here if it does not fit any of the other categories.

Setting no. of chars to be displayed in EditText using API

Postby manmath » Wed Mar 12, 2008 9:51 am

Hi,
I am able to set maximum number of characters to an edit text view using xml tag.But i am failed to do the same using API. My code is like this
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. EditText etPin0 = (EditText)findViewById(R.id.PIN0);
  3.  
  4. InputFilter [] maxLen={new InputFilter.LengthFilter(R.string.bank_pin_length)};
  5.  
  6. etPin0.setFilters(maxLen) ;
  7.  
  8.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Thanks
Manmath
manmath
Junior Developer
Junior Developer
 
Posts: 18
Joined: Fri Feb 15, 2008 1:30 pm
Location: India

Top

Postby plusminus » Wed Mar 12, 2008 7:17 pm

Hello manmath,

its like [font=Lucida Console]InputFilter.LengthFilter(place_a_integer_here); // not String or an ID[/font]

watch your R.java and look for the [font=Lucida Console]bank_pin_length[/font] its probably a really huge number ;)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby aksoffice » Fri Mar 28, 2008 4:22 am

hi manmath,


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. EditText etPin0 = (EditText)findViewById(R.id.PIN0);
  3.  
  4. InputFilter [] maxLen={new InputFilter.LengthFilter(R.string.bank_pin_length)};
  5.  
  6. etPin0.setFilters(maxLen) ;
  7.  
  8.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


instead of giving length from R file as string give an integer const or convert string using parse int and pass into LengthFilter like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. EditText etPin0 = (EditText)findViewById(R.id.PIN0);
  3.  
  4. InputFilter [] maxLen={new InputFilter.LengthFilter(int_value)};
  5.  
  6. etPin0.setFilters(maxLen) ;
  7.  
  8.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


hope will resolve ur prob.

rgds
AKS
aksoffice
Freshman
Freshman
 
Posts: 2
Joined: Tue Mar 25, 2008 5:43 am
Location: India

Postby manmath » Fri Mar 28, 2008 4:51 am

Thanks Plusminus and AKS for the valuable suggestion.
I am able to solve it.
manmath
Junior Developer
Junior Developer
 
Posts: 18
Joined: Fri Feb 15, 2008 1:30 pm
Location: India

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 26 guests