在黑莓如何重新安排ListField

编程入门 行业动态 更新时间:2024-10-18 14:26:21
本文介绍了在黑莓如何重新安排ListField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何重新安排的一 ListField ?我想选择点击黑莓(风暴和火炬)触摸手机的项目。选择我想在另一个列表项垂直(移动和拖动)的项目滚动(列表中的项目背景垂直滚动)或屏幕后。滚动后,将项目拖放任何地方上(在列表字段)屏幕。

How to re-arrange the items of a ListField? I want to select the item on click on Blackberry (Storm and Torch) Touch Phones. After select I want to (Move and Drag) Scroll item Vertically on another list item(list items scroll vertically in background) or screen. After scrolling, drop item any where on (in list field) Screen.

推荐答案

我也工作自定义列表场。只需点击列表项。点击之后ü可以移动(选择)的listItem垂直。如果u要放置在屏幕上任何地方比触控板再次点击。当u点击它会在该位置结帐的地方。这里是我的code。

i am also working on Custom list field. Just Click on listitem. after click U can move (selected) listItem vertically. if u want to place any where in screen than click again on trackpad. when u click it will be place on that position Checkout. here is my code.

public class ListDemo extends MainScreen implements ListFieldCallback { private VerticalFieldManager vfm, vfm_List; private ListField myList; private Vector vector; private String[] str_arr; int Height = Display.getHeight(); int Width = Display.getWidth(); int i ; boolean bool = true; int index = 0; private boolean hasFocus = false; private boolean b = true; public static int curSelected ; Channel obj; public ListDemo() { vector = new Vector(); for (i = 0; i < 8; i++) { obj = new Channel(); if (i == 0) { obj.setCh_icon("ajtak.jpg"); obj.setCh_Name("NightSuite"); obj.setCh_Move("move.png"); } else if (i == 1) { obj.setCh_icon("cnbc.jpg"); obj.setCh_Name("Shirts"); obj.setCh_Move("move.png"); } else if (i == 2) { obj.setCh_icon("zee.jpg"); obj.setCh_Name("Jeans"); obj.setCh_Move("move.png"); } else if (i == 3) { obj.setCh_icon("astha.jpg"); obj.setCh_Name("Bags"); obj.setCh_Move("move.png"); }else if (i == 4) { obj.setCh_icon("fox_news.jpg"); obj.setCh_Name("Coat"); obj.setCh_Move("move.png"); }else if (i == 5) { obj.setCh_icon("news.jpg"); obj.setCh_Name("Coat"); obj.setCh_Move("move.png"); } else if (i == 6) { obj.setCh_icon("star_news.jpg"); obj.setCh_Name("Coat"); obj.setCh_Move("move.png"); } else { obj.setCh_icon("assiant.jpg"); obj.setCh_Name("Shorts"); obj.setCh_Move("move.png"); } vector.addElement(obj); } init(); } public void init() { vfm = new VerticalFieldManager(USE_ALL_HEIGHT | USE_ALL_WIDTH) { protected void sublayout(int maxWidth, int maxHeight) { super.sublayout(maxWidth, maxHeight); setExtent(Width, Height); } }; vfm_List = new VerticalFieldManager(VERTICAL_SCROLL | VERTICAL_SCROLLBAR) { protected void sublayout(int maxHeight, int maxWidth) { super.sublayout(maxWidth, maxHeight); setExtent(Width, Height); } }; myList = new ListField() { public void onFocus(int direction){ hasFocus = true; } public void onUnfocus() { hasFocus = false; super.onUnfocus(); invalidate(); } public void paint(Graphics g) { if (hasFocus) { curSelected = getSelectedIndex(); } else { curSelected = -1; } super.paint(g); } }; myList.setCallback(this); myList.setRowHeight(50); myList.setFocusListener(new FocusChangeListener() { public void focusChanged(Field field, int eventType) { if (bool == false) { index = myList.getSelectedIndex(); Channel temp = (Channel) vector .elementAt(index); vector.removeElementAt(index); vector.insertElementAt(temp, curSelected); myList.invalidate(); } } }); for (int i = 0; i < vector.size(); i++) { myList.insert(i); } vfm_List.add(myList); vfm.add(vfm_List); add(vfm); } protected boolean navigationClick(int status, int time) { if(bool) { bool = false; } else { bool = true; } return true; } public void drawListRow(ListField list, Graphics g, int index, int y, int w) { String text = ((Channel) vector.elementAt(index)).getCh_Name(); Bitmap arrow = Bitmap.getBitmapResource(((Channel) vector.elementAt(index)).getCh_icon()); if(bool == false) { if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) { Bitmap move = Bitmap.getBitmapResource(((Channel) vector.elementAt(index)).getCh_Move()); g.drawBitmap(Width - 40, y + 13, 25, 25, move, 0, 0); } } g.setBackgroundColor(Color.LIGHTBLUE); g.setColor(Color.BLACK); g.drawBitmap(0, y + 10, 48, 35, arrow, 0, 0); g.drawText(text, 50, y + 18, 0, w); g.setColor(Color.WHITE); invalidate(); } public Object get(ListField list, int index) { return vector.elementAt(index); } public int indexOfList(ListField list, String p, int s) { return vector.indexOf(p, s); } public int getPreferredWidth(ListField list) { return Graphics.getScreenWidth(); } public void insert(String toInsert, int index) { vector.addElement(toInsert); } public void erase() { vector.removeAllElements(); }

}

下面是另一个渠道类

public class Channel { private String ch_Name; private String ch_icon; private String ch_move; public String getCh_Name() { return ch_Name; } public void setCh_Name(String ch_Name) { this.ch_Name = ch_Name; } public String getCh_icon() { return ch_icon; } public void setCh_icon(String ch_icon) { this.ch_icon = ch_icon; } public String getCh_Move() { return ch_move; } public void setCh_Move(String ch_move) { this.ch_move = ch_move; }

}

结帐其对触摸和nontouch工作。

Checkout its working on both touch and nontouch .

更多推荐

在黑莓如何重新安排ListField

本文发布于:2023-07-14 10:00:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:黑莓   ListField

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!