ブラックベリーでクリック可能なリストフィールドを作成して1つのアイテムをクリックすると、新しい画面が表示されるようにする方法を教えてください。BlackBerryリストフィールドの開発
1
A
答えて
1
私は、VerticalFieldManagerとJDE 5.0のカスタム拡張フィールドで同様の作業を行っています。
メイン画面に表示したいオブジェクトのリストがあるとします。
まず、リスト項目のFieldを拡張するクラスを作成し、そのペイントメソッド、レイアウトメソッド、およびotuherイベントを要件としてオーバーライドします。
次に、リストを表示するメイン画面を作成します。ループ内でオブジェクトリストを作成したら、各オブジェクトモデルを以前に作成したフィールドのコンストラクタに渡します。そのフィールドにfieldChangedイベントを追加し、verticalFieldManagerに追加します。
イベント(fieldChangedイベントなど)をクリックして別の画面に表示する必要があります。
最後に、リスト項目のオブジェクトの詳細を表示するために必要な引数を取る詳細画面を作成します。メイン画面の実装のfieldChangedイベントで、オブジェクトを詳細画面に渡し、詳細画面を押します。
また、thisアプローチが役立つ場合があります。
例:
カスタムフィールド:
public class CListItemField extends Field {
private CListItemModel model;
public CListItemField(CListItemModel _model, long style) {
super(style);
this.model = _model;
}
public CListItemModel getModel() {
return this.model;
}
// overrides
public int getPreferredHeight() {
//return custom height
}
public int getPreferredWidth() {
//return custom width
}
protected void layout(int width, int height) {
setExtent(Math.min(width, getPreferredWidth()), getPreferredHeight());
}
protected void paint(Graphics g) {
//custom paint stuff (borders, fontstyle, text position, icons etc.)
if (isFocus()) {
//focused item display settings
} else {
//item display settings
}
}
protected void drawFocus(Graphics graphics, boolean on) {
}
public boolean isFocusable() {
return true;
}
protected void onFocus(int direction) {
super.onFocus(direction);
invalidate();
}
protected void onUnfocus() {
super.onUnfocus();
invalidate();
}
protected boolean navigationClick(int status, int time) {
fieldChangeNotify(0);
return true;
}
protected boolean keyChar(char character, int status, int time) {
//send key event to listener
if (character == Keypad.KEY_ENTER) {
fieldChangeNotify(0);
return true;
}
return super.keyChar(character, status, time);
}
}
一覧画面:
public class ScreenListbox extends MainScreen implements FieldChangeListener, FocusChangeListener {
private VerticalFieldManager verticalField;
private Vector listItemVector;
public ScreenOttoInbox(String title) {
super(title, Manager.NO_VERTICAL_SCROLL);
setData();
setComponents();
}
private void setData() {
//populate listItemVector according to your business (ie. read json response then parse it and collect it to a vector)
}
public void setComponents() {
verticalField = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
setListContent(verticalField, listItemVector);
add(verticalField);
}
private void setListContent(VerticalFieldManager field, Vector vector) {
try {
int vlen = vector.size();
for (int i = 0; i < vlen; i++) {
CListItemModel model = (CListItemModel) vector.elementAt(i);
CListItemField itemField = new CListItemField(model, Field.FOCUSABLE | Field.ACTION_INVOKE);
itemField.setChangeListener(this);
itemField.setFocusListener(this);
field.add(itemField);
}
} catch (Exception ex) { }
}
protected boolean onSavePrompt() {
return true;
}
public void fieldChanged(Field field, int context) {
//custom field's click/touch event handler
CListItemField itemField = (CListItemField) field;
ScreenItemDetail scrDetail = new ScreenItemDetail(itemField.getModel());
ScreenUtil.pushScreenWithLoader(scrDetail,true);
}
protected void onDisplay() {
super.onDisplay();
}
}
1
は、以下のようなクラスを作成します。
import java.util.Vector;
import net.rim.device.api.collection.util.SparseList;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;
public class CListCallback implements ListFieldCallback {
private String[] resource;
private int rgb=Color.BLACK;
Vector elements;
Bitmap arraow;
public CListCallback(String[] resources){
this.resource=resources;
}
public void drawListRow(ListField listField, Graphics graphics, int index,
int y, int width) {
String text=(String) get(listField, index);
graphics.setColor(rgb);
graphics.drawText(text,60,y+25);
graphics.drawLine(0, y+59, DConfig.disWidth, y+59);
}
public Object get(ListField listField, int index) {
return resource[index];
}
public int getPreferredWidth(ListField listField) {
return DConfig.disWidth+10;
}
public int indexOfList(ListField listField, String prefix, int start) {
return -1;
}
}
MainScreenクラスで上記のクラスを使用します。 it.itが
関連する問題
- 1. BlackBerryアプリケーションの開発
- 2. iPhone、Android、Blackberryのモバイル開発
- 3. Blackberry web-applicationの開発
- 4. Visual StudioでのBlackberryの開発
- 5. Blackberryの開発:アーキテクチャのベストプラクティスとパターン
- 6. スクリプト言語のBlackberry開発ですか?
- 7. Flash CS5 AndroidとBlackberryの開発
- 8. blackberryリストフィールドに検索フィールドを追加する
- 9. リストフィールドのブラックベリー
- 10. Sybaseの無償のプラットフォーム2.0(BlackBerry開発用)
- 11. BlackBerry開発のガイドはありますか?
- 12. BlackBerry開発のBlackBerry_App_Descriptor.xmlを参照しています
- 13. 複数の列リストフィールド
- 14. SQLクエリ - リストフィールド
- 15. Blackberry Java開発から電子メールを送信
- 16. BlackBerry - ブランドアプリケーションを開発することは可能ですか?
- 17. Mac OSでBlackberryアプリを開発するには?
- 18. ブラックベリーの嵐とトーチのリストフィールド
- 19. Blackberryのハイブリッド(native + html5)アプリを開発することは可能ですか?
- 20. BlackBerry:リストフィールド - フィールド全体ではなくテキストのみを強調表示する方法
- 21. デバイスにBlackBerryアプリケーションを展開中にエラーが発生しました
- 22. Mac OS XでBlackberry Applnを開発する際に助けが必要
- 23. SharePoint 2010 - リストフィールドのレンダリングと動作のカスタマイズ
- 24. SignataureToolがBlackberryで開かない
- 25. Blackberry SimulatorでSQLiteデータベースを開く問題?
- 26. Blackberry Programmingを開始するには?
- 27. Java morphia - リストフィールドの値による照会
- 28. リストフィールドのアクセス許可を設定する
- 29. Web開発とデスクトップ開発のASP.net
- 30. Java:メソッドで使用されるリストフィールド
に動作します
ザッツ私は、上記の例を試してみましたが、私は従うことができないですので、多くのものがあります。誰も簡単なコードで私を助けることができます –