how to display text and images in single view

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

how to display text and images in single view

Postby makrandmane » Fri May 15, 2009 5:56 am

Hello

currently I am developing a quiz application. the quiz pattern is one question and four answers. for answer cell i am using text area. and its working fine , but now I want to show some images in Answer cell. how i can do this ? can use different view ? which view able to show text as well as image at same time.


please help me !!!!!!!!
makrandmane
Junior Developer
Junior Developer
 
Posts: 11
Joined: Mon Mar 23, 2009 1:07 pm

Top

Use TextView

Postby satishkumar_lskin » Fri May 15, 2009 9:47 am

Hi,
U can use TextView for ur requirement . Here is a sample activity :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class TextViewDrawable extends Activity {
  3.  
  4.     /** Called when the activity is first created. */
  5.  
  6.     @Override
  7.  
  8.     public void onCreate(Bundle savedInstanceState) {
  9.  
  10.         super.onCreate(savedInstanceState);
  11.  
  12.         setContentView(R.layout.main);
  13.  
  14.         createTextWithDrawable();
  15.  
  16.     }
  17.  
  18.  
  19.  
  20.         private void createTextWithDrawable() {
  21.  
  22.                 // TODO Auto-generated method stub
  23.  
  24.                 TextView textView = (TextView) findViewById(R.id.text_with_drawable);
  25.  
  26.                 Drawable drawable = getResources().getDrawable(R.drawable.my_icon);
  27.  
  28.  
  29.  
  30.                 textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
  31.  
  32.         }
  33.  
  34. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


The method setCompoundDrawablesWithIntrinsicBounds() enables you to add images to TextView.

Regards
Satish
satishkumar_lskin
Developer
Developer
 
Posts: 32
Joined: Mon Oct 20, 2008 8:15 am
Location: Coimbatore , TamilNadu, India

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests