當前位置: 首頁>>代碼示例>>Java>>正文


Java WearableListView.scrollToPosition方法代碼示例

本文整理匯總了Java中android.support.wearable.view.WearableListView.scrollToPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java WearableListView.scrollToPosition方法的具體用法?Java WearableListView.scrollToPosition怎麽用?Java WearableListView.scrollToPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.wearable.view.WearableListView的用法示例。


在下文中一共展示了WearableListView.scrollToPosition方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_config_wear_default);

    final Configuration parent = (Configuration) getIntent().getSerializableExtra(EXTRA_PARENT);
    final int selectedIndex = getIntent().getIntExtra(EXTRA_SELECTED_INDEX, 0);

    final WearableListView listView = (WearableListView) findViewById(R.id.list_config);
    listView.setAdapter(new SelectionAdapter(getItems(parent)));
    listView.scrollToPosition(selectedIndex);
    listView.setClickListener(new WearableListView.ClickListener() {
        @Override
        public void onClick(final WearableListView.ViewHolder viewHolder) {
            final Serializable selection = (Serializable) viewHolder.itemView.getTag();
            final Intent data = new Intent();
            data.putExtra(EXTRA_PARENT, parent);
            data.putExtra(EXTRA_RESULT, selection);
            setResult(RESULT_OK, data);
            finish();
        }

        @Override
        public void onTopEmptyRegionClick() { }
    });
}
 
開發者ID:rycus86,項目名稱:StringTheory,代碼行數:27,代碼來源:BaseWearableSubConfigurationActivity.java

示例2: onCreate

import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.preference_list);

    loadIntentExtras();
    checkRequiredExtras();

    final WearableListView list = (WearableListView) findViewById(android.R.id.list);
    list.setAdapter(new PreferenceEntriesAdapter());
    list.scrollToPosition(getIntent().getIntExtra(EXTRA_CURRENT_VALUE, 0));
    list.setClickListener(this);
}
 
開發者ID:LadyViktoria,項目名稱:wearDrip,代碼行數:13,代碼來源:ListChooserActivity.java

示例3: onCreate

import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_config);

    // Get the list component from the layout of the activity
    WearableListView listView =
            (WearableListView) findViewById(R.id.wearable_list);

    mElements = getResources().getStringArray(R.array.currency_names);
    mSymbols = getResources().getStringArray(R.array.currency_symbols);
    mTickers = getResources().getStringArray(R.array.currency_tickers);
    mInvert = getResources().getIntArray(R.array.currency_invert);


    // Assign an adapter to the list
    listView.setAdapter(new Adapter(this, mElements));

    // Set a click listener
    listView.setClickListener(this);

    mComplicationId = getIntent().getIntExtra(
            android.support.wearable.complications.ComplicationProviderService.EXTRA_CONFIG_COMPLICATION_ID, -1);

    int selected = getSharedPreferences("config", 0).getInt(mComplicationId + "_selected_position", 0);
    listView.scrollToPosition(selected);
}
 
開發者ID:dps,項目名稱:wear-exchangerates,代碼行數:28,代碼來源:ConfigActivity.java

示例4: onCreateView

import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    appData = AppData.getInstance(getActivity().getApplicationContext());
    saveLoadDataJSON = new SaveLoadDataJSON(getActivity().getApplicationContext());
    View view = inflater.inflate(R.layout.color_fragment, container, false);
    WearableListView wearableListView = (WearableListView) view.findViewById(R.id.wlv_color);
    adapter = new ColorWearableListViewAdapter(inflater, getActivity());
    wearableListView.setAdapter(adapter);
    wearableListView.setClickListener(new WearableListView.ClickListener() {
        @Override
        public void onClick(WearableListView.ViewHolder viewHolder) {
            appData.getLastTimer().setColor(adapter.colors.get(viewHolder.getAdapterPosition()));
            saveLoadDataJSON.saveJSON(appData);
            replaceFragment();
        }

        @Override
        public void onTopEmptyRegionClick() {

        }
    });
    wearableListView.addOnCentralPositionChangedListener(new WearableListView.OnCentralPositionChangedListener() {
        @Override
        public void onCentralPositionChanged(int i) {
            adapter.centralPosition = i;
        }
    });
    wearableListView.scrollToPosition(adapter.getIndexColor(appData.getLastTimer().getColor().color));
    return view;
}
 
開發者ID:khasang,項目名稱:Poti,代碼行數:32,代碼來源:ColorFragment.java

示例5: initLayout

import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
private void initLayout() {
    setContentView(R.layout.activity_main);
    appData = AppData.getInstance(getApplicationContext());
    if (appData.getLastTimer() != null && appData.getLastTimer().getDuration() == 0L) {
        appData.timers.remove(appData.getIndexLastTimer());
    }
    wearableTimers = initArray(appData);
    final WearableListView wearableListView = (WearableListView) findViewById(R.id.timers_listview);
    final TimersWearableAdapter settingsAdapter = new TimersWearableAdapter(LayoutInflater.from(MainActivity.this), wearableTimers, MainActivity.this);
    wearableListView.setAdapter(settingsAdapter);
    wearableListView.addOnCentralPositionChangedListener(new WearableListView.OnCentralPositionChangedListener() {
        @Override
        public void onCentralPositionChanged(int i) {
            if (i - 1 >= 0 && i - 1 < appData.timers.size()) {
                appData.setLastTimer(i - 1);
            }
        }

    });
    int indexArr = appData.timers.indexOf(appData.getLastTimer());
    if (indexArr >= 0
            && indexArr <= appData.timers.size() - 1
            && indexArr <= wearableTimers.size()
            && appData.timers.size() != 0) {
        wearableListView.scrollToPosition(appData.timers.indexOf(appData.getLastTimer()) + 1);
    } else {
        wearableListView.scrollToPosition(0);
    }
}
 
開發者ID:khasang,項目名稱:Poti,代碼行數:30,代碼來源:MainActivity.java

示例6: onCreate

import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.preference_list);

    loadIntentExtras();
    checkRequiredExtras();

    final WearableListView list = (WearableListView) findViewById(android.R.id.list);
    list.setAdapter(new PreferenceEntriesAdapter());
    list.scrollToPosition(getIntent().getIntExtra(EXTRA_CURRENT_VALUE, 0));
    list.setClickListener(this);
}
 
開發者ID:sssemil,項目名稱:Advanced-Settings-for-Android-Wear,代碼行數:14,代碼來源:ListChooserActivity.java

示例7: onCreateView

import android.support.wearable.view.WearableListView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    appData = AppData.getInstance(getActivity().getApplicationContext());
    View view = inflater.inflate(R.layout.additional_options_fragment, container, false);
    WearableListView wearableListView = (WearableListView) view.findViewById(R.id.wlv_additional_options);
    adapter = new AdditionalOptionsWearableListViewAdapter(inflater, getActivity());
    wearableListView.setAdapter(adapter);
    wearableListView.setClickListener(new WearableListView.ClickListener() {
        @Override
        public void onClick(WearableListView.ViewHolder viewHolder) {
            int position = viewHolder.getAdapterPosition();
            switch (position) {
                case NAME_POSITION:
                    displaySpeechRecognizer();
                    break;
                case COLOR_POSITION:
                    FragmentManager fragmentManager = getFragmentManager();
                    fragmentManager.beginTransaction()
                            .replace(R.id.frame_layout, ColorFragment.newInstance())
                            .commit();
                    break;
                case VIBRATION_POSITION:
                    Intent intent = new Intent(getActivity().getApplicationContext(), VibrateActivity.class);
                    startActivity(intent);
                    break;
                case CYCLE_POSITION:
                    break;
                default:
                    break;
            }
        }

        @Override
        public void onTopEmptyRegionClick() {

        }
    });
    wearableListView.addOnCentralPositionChangedListener(new WearableListView.OnCentralPositionChangedListener() {
        @Override
        public void onCentralPositionChanged(int i) {
            appData.positionAdditionalOptions = i;
        }
    });
    wearableListView.scrollToPosition(appData.positionAdditionalOptions);
    return view;
}
 
開發者ID:khasang,項目名稱:Poti,代碼行數:48,代碼來源:AdditionalOptionsFragment.java


注:本文中的android.support.wearable.view.WearableListView.scrollToPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。