2012-06-18 1 views
0

мой Custom_Field класс так:Как добавить bitmapfield или clicklistener в полевой класс?

public class Custom_BottomField extends Field { 

private Bitmap _backgroundBitmap = Bitmap 
     .getBitmapResource("footer_bar.png"); 

private Bitmap finance = Bitmap.getBitmapResource("icon_economy.png"), 
     special = Bitmap.getBitmapResource("icon_title.png"), 
     forum = Bitmap.getBitmapResource("icon_forum.png"), 
     discussion = Bitmap.getBitmapResource("icon_discussion.png"), 
     other = Bitmap.getBitmapResource("icon_other.png"); 

private BitmapField financebtn, specialbtn, forumbtn, discussionbtn, 
     otherbtn; 

Custom_BottomField() { 
    Background background = BackgroundFactory 
      .createBitmapBackground(_backgroundBitmap); 
    setBackground(background); 
} 

protected void layout(int width, int height) { 
    width = Math.min(width, getPreferredWidth()); 
    height = Math.min(height, getPreferredHeight()); 
    setExtent(width, height); 
} 

public int getPreferredHeight() { 
    return 70; 
} 

public int getPreferredWidth() { 
    return Display.getWidth(); 
} 

protected void paint(Graphics graphics) { 
    int rectHeight = getPreferredHeight(); 
    int rectWidth = getPreferredWidth(); 
    graphics.drawRect(0, 0, rectWidth, rectHeight); 
    graphics.drawBitmap(getGap(), 5, finance.getWidth(), 
      finance.getHeight(), finance, 0, 0); 
    graphics.drawBitmap(rectWidth/5 + getGap(), 5, special.getWidth(), 
      special.getHeight(), special, 0, 0); 
    graphics.drawBitmap(rectWidth * 2/5 + getGap(), 5, forum.getWidth(), 
      forum.getHeight(), forum, 0, 0); 
    graphics.drawBitmap(rectWidth * 3/5 + getGap(), 5, 
      discussion.getWidth(), discussion.getHeight(), discussion, 0, 0); 
    graphics.drawBitmap(rectWidth * 4/5 + getGap(), 5, other.getWidth(), 
      other.getHeight(), other, 0, 0); 
} 

private int getGap() { 
    return ((getPreferredWidth()/5) - finance.getWidth())/2; 
} 

private void Button() { 
    financebtn = new BitmapField(finance, BitmapField.FOCUSABLE) { 
     protected boolean navigationClick(int status, int time) { 
      MyApp.getUiApplication().pushScreen(new Main_ParticulatCategoryAllNews()); 
      return true; 
     } 
    }; 
} 
} 

выше класс выделенный в this изображение

Я не могу добавить BitmapField в Field классе, потому что я хочу, чтобы нажать на кнопку, чтобы перейти к Main_ParticulatCategoryAllNews класса.

+0

Я не могу добавить BitmapField в 'Field' классе, потому что я хочу, чтобы нажать на кнопку, чтобы перейти к' классу Main_ParticulatCategoryAllNews'. - неясно. – Rupak

+0

Я редактировал класс с добавленным изображением –

+0

Вам нужно изменить подход. Вы можете создать HorizontalFieldManager, и на нем вы можете добавить пять ButtonField. Настройка «HorizontalFieldManager» может быть выполнена с настройкой фона изображения. И вместо 'ButtonField' вы можете реализовать« CustomButtonField »с изображением. – Rupak

ответ

0

решена расширяет HorizontalFieldManager и используя add()

 Смежные вопросы

  • Нет связанных вопросов^_^