Несколько макетов в SmartWatch

Кто-нибудь знает, как сделать множественную раскладку в SmartWatch? В настоящее время у меня есть только один макет, когда я прокручиваю влево, я хочу иметь другой макет.

Чтобы сделать первый макет, я уже сделал так:

public class HelloWatchExtension extends ControlExtension{

int width;
int height;

RelativeLayout layout;
RelativeLayout layut;
Canvas canvas;
Bitmap bitmap;
TextView textView;

public HelloWatchExtension(Context context, String hostAppPackageName) {
    super(context, hostAppPackageName);

    width = getSupportedControlWidth(context);
    height = getSupportedControlHeight(context);

    layout = new RelativeLayout(context);
    textView = new TextView(context);
    textView.setText("Hello watch!");
    textView.setTextSize(9);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(Color.WHITE);
    textView.layout(0, 0, width, height);
    layout.addView(textView);

}

Я не знаю, как изменить макет или добавить другой макет. Я пытался использовать onSwipe (ниже), но это не работает:

public void onSwipe(int direction) {
        switch (direction) {
   case Control.Intents.SWIPE_DIRECTION_UP:
       break;
   case Control.Intents.SWIPE_DIRECTION_LEFT:
                    layut = new RelativeLayout(context);
            textView.setText("Helhuhch!");
            textView.setTextSize(9);
            layut.addView(textView);
       break;
   case Control.Intents.SWIPE_DIRECTION_DOWN:
       break;
   case Control.Intents.SWIPE_DIRECTION_RIGHT:
       break;
   default:
       break;

Кто-нибудь знает, как это сделать?


person eng    schedule 17.12.2013    source источник


Ответы (1)


Я полагаю, вы говорите о SmartWatch 1, а не о SmartWatch 2? Для SW1 вам нужно вызвать showBitmap(), чтобы нарисовать макет на часах. Полный пример кода см. в проекте ControlSample в папке /samples пакета Sony Add-on SDK.

        // Create background bitmap for animation.
        mBackground = Bitmap.createBitmap(width, height, BITMAP_CONFIG);
        // Set default density to avoid scaling.
        mBackground.setDensity(DisplayMetrics.DENSITY_DEFAULT);

        LinearLayout root = new LinearLayout(mContext);
        root.setLayoutParams(new LayoutParams(width, height));

        LinearLayout sampleLayout = (LinearLayout)LinearLayout.inflate(mContext,
                R.layout.sample_control, root);
        ((TextView)sampleLayout.findViewById(R.id.sample_control_text)).setText(packageName);
        sampleLayout.measure(width, height);
        sampleLayout.layout(0, 0, sampleLayout.getMeasuredWidth(),
                sampleLayout.getMeasuredHeight());

        Canvas canvas = new Canvas(mBackground);
        sampleLayout.draw(canvas);

        showBitmap(mBackground);
person mldeveloper    schedule 17.12.2013