Draw Bitmaps dependent on entries in a list

All your problems with Audio, Video and Images.

Draw Bitmaps dependent on entries in a list

Postby felixad » Sat May 15, 2010 3:12 pm

Hello

I am new in android programming. I want to do create dynamically a simple list in this form:
(String name, String description, int position x, int position y).

Dependent on the number of the list entries I want to draw pictures on my canvas.

First problems:
I don't know how to create my string. I thought something like that:
ArrayList<String, String, Integer, Integer> myArraysList = newArrayList();

Second problem:
How can I draw bitmaps dependent on entries in my list?

I thought like this:

Create a DrawBitmap Class:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.example.drawsinglebitmap;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.content.Context;
  8.  
  9. import android.graphics.Bitmap;
  10.  
  11. import android.graphics.BitmapFactory;
  12.  
  13. import android.graphics.Canvas;
  14.  
  15. import android.graphics.Color;
  16.  
  17. import android.os.Bundle;
  18.  
  19. import android.view.View;
  20.  
  21. import android.view.Window;
  22.  
  23.  
  24.  
  25. public class DrawBitmap extends Activity {
  26.  
  27.     @Override
  28.  
  29.     public void onCreate(Bundle savedInstanceState) {
  30.  
  31.         super.onCreate(savedInstanceState);
  32.  
  33.         requestWindowFeature(Window.FEATURE_NO_TITLE);
  34.  
  35.         setContentView(new Panel(this));
  36.  
  37.     }
  38.  
  39.  
  40.  
  41.     class Panel extends View {
  42.  
  43.         public Panel(Context context) {
  44.  
  45.             super(context);
  46.  
  47.         }
  48.  
  49.  
  50.  
  51.         @Override
  52.  
  53.         public void onDraw(Canvas canvas) {
  54.  
  55.             Bitmap _scratch = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
  56.  
  57.             canvas.drawColor(Color.BLACK);
  58.  
  59.             canvas.drawBitmap(_scratch, 10, 10, null);
  60.  
  61.         }
  62.  
  63.     }
  64.  
  65. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Import the class in my main java file:
import com.example.DrawBitmap;

Create a instace and run onDraw()::
DrawBitmap myBitmap;
myBitmap.onDraw();

But its absolutely not correct.

Can anybody help me, to find the right way to draw bitmaps?

Thanks a lot.

Felix
felixad
Freshman
Freshman
 
Posts: 4
Joined: Sat Mar 20, 2010 10:04 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 30 guests