Java Code Examples for android.widget.ListView#setClickable()

The following examples show how to use android.widget.ListView#setClickable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScanView.java    From SensorTag-CC2650 with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  // Log.i(TAG, "onCreateView");

  // The last two arguments ensure LayoutParams are inflated properly.
  View view = inflater.inflate(R.layout.fragment_scan, container, false);

  mActivity = (MainActivity) getActivity();
  mContext = mActivity.getApplicationContext();

  // Initialize widgets
  mStatus = (TextView) view.findViewById(R.id.status);
  mBtnScan = (Button) view.findViewById(R.id.btn_scan);
  mDeviceListView = (ListView) view.findViewById(R.id.device_list);
  mDeviceListView.setClickable(true);
  mDeviceListView.setOnItemClickListener(mDeviceClickListener);
  mEmptyMsg = (TextView)view.findViewById(R.id.no_device);    
  mBusy = false;
  
  // Alert parent activity
  mActivity.onScanViewReady(view);

  return view;
}
 
Example 2
Source File: MainActivity.java    From Acastus with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Update list.
 *
 * @param data the data
 */
private void updateList(String[] data) {
    ArrayAdapter<?> adapter = new ArrayAdapter<Object>(this, android.R.layout.simple_selectable_list_item, data);
    resultsList = (ListView) findViewById(R.id.resultsList);
    resultsList.setAdapter(adapter);
    resultsList.setClickable(true);
}
 
Example 3
Source File: FaBoServiceListActivity.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
                         final Bundle savedInstanceState) {
    setHasOptionsMenu(true);

    View root = inflater.inflate(R.layout.fragment_service_list_viewer, container, false);

    mListAdapter = new ServiceListAdapter(getActivity(), getProvider(), false);

    ListView listView = root.findViewById(R.id.activity_fabo_service_list_view);
    listView.setAdapter(mListAdapter);
    listView.setItemsCanFocus(true);
    listView.setClickable(true);
    listView.setOnItemClickListener((parent, view, position, id) -> {
        Object service = mListAdapter.getItem(position);
        if (service instanceof VirtualService) {
            openVirtualServiceActivity((VirtualService) service);
        }
    });

    Button newServiceButton = root.findViewById(R.id.activity_fabo_service_add_btn);
    newServiceButton.setOnClickListener((v) -> {
        openVirtualServiceActivity(null);
    });

    return root;
}
 
Example 4
Source File: HdmiProfileSelectActivity.java    From SecondScreen with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quick_launch);
    setTitle(getResources().getString(R.string.select_profile));

    // Get array of profiles
    final String[][] profileList = U.listProfiles(this, "show_list", R.string.show_list);

    // If there are no saved profiles, then show a toast message and exit
    if(profileList == null) {
        U.showToast(this, R.string.no_profiles_found);
        finish();
    } else {
        // Create ArrayList and populate with list of profiles
        ArrayList<String> arrayList = new ArrayList<>(profileList[1].length);
        arrayList.addAll(Arrays.asList(profileList[1]));

        // Create the custom adapter to bind the array to the ListView
        final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, arrayList);

        // Display the ListView
        final ListView listView = findViewById(R.id.listView2);
        listView.setPadding(getResources().getDimensionPixelSize(R.dimen.list_view_padding), 0, 0, 0);
        listView.setAdapter(adapter);
        listView.setClickable(true);
        listView.setOnItemClickListener((arg0, arg1, position, arg3) -> {
            SharedPreferences prefMain = U.getPrefMain(this);
            SharedPreferences.Editor editor = prefMain.edit();
            editor.putString("hdmi_load_profile", profileList[0][position]);
            editor.apply();

            finish();
        });
    }
}
 
Example 5
Source File: TaskerConditionActivity.java    From SecondScreen with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quick_launch);
    setTitle(getResources().getString(R.string.select_profile));

    // Get array of profiles
    final String[][] profileList = U.listProfiles(this, "any_profile", R.string.any_profile);

    // If there are no saved profiles, then show a toast message and exit
    if(profileList == null) {
        U.showToast(this, R.string.no_profiles_found);
        finish();
    } else {
        // Create ArrayList and populate with list of profiles
        ArrayList<String> arrayList = new ArrayList<>(profileList[1].length);
        arrayList.addAll(Arrays.asList(profileList[1]));

        // Create the custom adapter to bind the array to the ListView
        final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, arrayList);

        // Display the ListView
        final ListView listView = findViewById(R.id.listView2);
        listView.setAdapter(adapter);
        listView.setClickable(true);
        listView.setOnItemClickListener((arg0, arg1, position, arg3) -> {
            try {
                loadProfile(profileList[0][position]);
            } catch (IOException e) {
                U.showToast(this, R.string.error_loading_profile);
            }
        });
    }
}
 
Example 6
Source File: Phone_frag.java    From ui with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View myView = inflater.inflate(R.layout.phone_frag, container, false);

       ListView list = (ListView) myView.findViewById(R.id.ListView01);
       list.setClickable(true);

       final List<Phonebook> listOfPhonebook = new ArrayList<Phonebook>();
       listOfPhonebook.add(new Phonebook("Test", "9981728", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test1", "1234455", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test2", "00000", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test3", "00000", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test4", "00000", "test4test.com"));
       listOfPhonebook.add(new Phonebook("Test5", "00000", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test6", "00000", "[email protected]"));

       PhonebookAdapter adapter = new PhonebookAdapter(myContext, listOfPhonebook);

       list.setOnItemClickListener(new OnItemClickListener() {

           @Override
           public void onItemClick(AdapterView<?> arg0, View view, int position, long index) {
               showToast(listOfPhonebook.get(position).getName());
           }
       });

       list.setAdapter(adapter);
       
       return myView;
   }
 
Example 7
Source File: Phonebook_Fragment.java    From ui with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View myView = inflater.inflate(R.layout.phonebook_fragment, container, false);

    ListView list = myView.findViewById(R.id.ListView01);
    list.setClickable(true);

    final List<Phonebook_DataModel> listOfPhonebook = new ArrayList<Phonebook_DataModel>();
    listOfPhonebook.add(new Phonebook_DataModel("Test", "9981728", "[email protected]"));
    listOfPhonebook.add(new Phonebook_DataModel("Test1", "1234455", "[email protected]"));
    listOfPhonebook.add(new Phonebook_DataModel("Test2", "00000", "[email protected]"));
    listOfPhonebook.add(new Phonebook_DataModel("Test3", "00000", "[email protected]"));
    listOfPhonebook.add(new Phonebook_DataModel("Test4", "00000", "test4test.com"));
    listOfPhonebook.add(new Phonebook_DataModel("Test5", "00000", "[email protected]"));
    listOfPhonebook.add(new Phonebook_DataModel("Test6", "00000", "[email protected]"));

    Phonebook_myAdapter adapter = new Phonebook_myAdapter(myContext, listOfPhonebook);

    list.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position, long index) {
            showToast(listOfPhonebook.get(position).getName());
        }
    });

    list.setAdapter(adapter);

    return myView;
}
 
Example 8
Source File: HomeActivity.java    From android-clean-code with MIT License 4 votes vote down vote up
private void createFlightListView() {
    ListView listView = (ListView) findViewById(R.id.listOfFlights);
    listView.setAdapter(new FlightListAdapter());
    listView.setClickable(true);
    listView.setOnItemClickListener(router);
}
 
Example 9
Source File: FaBoServiceListActivity.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
                         final Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_service_list_remover, container, false);

    mListAdapter = new ServiceListAdapter(getActivity(), getProvider(), true);
    mListAdapter.setOnStatusChangeListener(this);

    ListView listView = root.findViewById(R.id.activity_fabo_service_list_view);
    listView.setAdapter(mListAdapter);
    listView.setItemsCanFocus(true);
    listView.setClickable(true);
    listView.setOnItemClickListener((parent, view, position, id) -> {
        Object service = mListAdapter.getItem(position);
        if (service instanceof VirtualService) {
            VirtualService vs = (VirtualService) service;
            if (vs.isOnline()) {
                showOnlineDialog();
            } else {
                mListAdapter.toggleCheckBox((DConnectService) service);
                CheckBox checkBox = view.findViewById(R.id.activity_fabo_service_removal_checkbox);
                if (checkBox != null) {
                    checkBox.toggle();
                }
            }
        } else {
            showImmortalDialog();
        }
    });

    Button cancelButton = root.findViewById(R.id.activity_fabo_service_cancel_btn);
    cancelButton.setOnClickListener((v) -> {
        showViewerFragment();
    });

    mRemoveBtn = (Button) root.findViewById(R.id.activity_fabo_service_remove_btn);
    mRemoveBtn.setOnClickListener((v) -> {
        showRemovalConfirmation();
    });
    mRemoveBtn.setEnabled(false);

    return root;
}
 
Example 10
Source File: FragmentStatusList.java    From Rumble with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    Bundle args = getArguments();
    if(args != null) {
        this.filter_gid = args.getString("GroupID");
        this.filter_uid = args.getString("ContactID");
        this.filter_hashtag = args.getString("Hashtag");
        this.noCoordinatorLayout = args.getBoolean("noCoordinatorLayout");
    }

    /*
     * This fragment is shown in three activities: the HomeActivity, the GroupDetail activity
     * and the ContactDetail activity. For HomeActivity and GroupDetail, I need the floating
     * action button to compose message and I need it to disappear when I scroll down so I need
     * this fragment to embeds it in a CoordinatorLayout to enable this effect.
     *
     * However for ContactDetail activity, I need a CoordinatorLayout for the whole activity
     * in order to hide the collapsingtoolbar whenever I scroll down. Unfortunately it conflicts
     * with the coordinatorlayout I use for this very fragmentStatusList. Because I don't need
     * the compose button to display the status to a specific contact, I created two different
     * layout to avoid conflicts and use the argument noCoordinatorLayout to decide which one.
     */
    if(noCoordinatorLayout) {
        mView = inflater.inflate(R.layout.fragment_status_list_no_coordinatorlayout, container, false);
    } else {
        mView = inflater.inflate(R.layout.fragment_status_list, container, false);
    }

    // the filters
    filters = (ListView) (mView.findViewById(R.id.filter_list));
    filterListAdapter = new FilterListAdapter(getActivity(), this);
    filters.setAdapter(filterListAdapter);
    filters.setClickable(false);
    filters.setVisibility(View.GONE);

    // refreshing the list of status by pulling down, disabled for ContactDetail
    swipeLayout = (SwipeRefreshLayout) mView.findViewById(R.id.swipe_container);
    if(noCoordinatorLayout)
        swipeLayout.setEnabled(false);
    else
        swipeLayout.setOnRefreshListener(this);


    /*
    final float density = getResources().getDisplayMetrics().density;
    final int swipeDistance = Math.round(64 * density);
    swipeLayout.setProgressViewOffset(true, 10, 10+swipeDistance);
    */

    // the compose button, disabled for ContactDetail
    composeFAB = (FloatingActionButton) mView.findViewById(R.id.compose_fab);
    if(noCoordinatorLayout)
        composeFAB.setVisibility(View.GONE);
    else
        composeFAB.setOnClickListener(onFabClicked);

    // the list of status
    mRecyclerView = (RecyclerView) mView.findViewById(R.id.status_list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    statusRecyclerAdapter = new StatusRecyclerAdapter(getActivity(), this);
    mRecyclerView.setAdapter(statusRecyclerAdapter);
    mRecyclerView.addOnScrollListener(loadMore);

    // now get the latest status
    loadingMore = false;
    noMoreStatusToLoad = false;
    refreshStatuses();

    EventBus.getDefault().register(this);

    return mView;
}
 
Example 11
Source File: HdmiActivity.java    From SecondScreen with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private void showMenu() {
    setContentView(R.layout.activity_hdmi);
    setTitle(getResources().getString(R.string.hdmi_connected));
    menu = true;

    TextView header = findViewById(R.id.hdmi_header);
    header.setText(getString(R.string.hdmi_connected));

    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        header.setTypeface(Typeface.DEFAULT);

    // Close notification drawer
    Intent closeDrawer = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    sendBroadcast(closeDrawer);

    DisplayManager dm = (DisplayManager) getApplicationContext().getSystemService(DISPLAY_SERVICE);
    DisplayMetrics metrics = new DisplayMetrics();

    Display[] displays = dm.getDisplays();
    displays[displays.length - 1].getRealMetrics(metrics);

    String extScreenRes = metrics.widthPixels + "x" + metrics.heightPixels;

    switch(extScreenRes) {
        case "3840x2160":
            extScreenRes = getResources().getStringArray(R.array.pref_resolution_list)[1];
            break;
        case "1920x1080":
            extScreenRes = getResources().getStringArray(R.array.pref_resolution_list)[2];
            break;
        case "1280x720":
            extScreenRes = getResources().getStringArray(R.array.pref_resolution_list)[3];
            break;
        case "854x480":
            extScreenRes = getResources().getStringArray(R.array.pref_resolution_list)[4];
            break;
    }

    TextView textView = findViewById(R.id.hdmiTextView);
    textView.setText(extScreenRes);

    // Get array of profiles
    final String[][] profileList = U.listProfiles(this);

    // If there are no saved profiles, then show a toast message and exit
    if(profileList == null) {
        U.showToast(this, R.string.no_profiles_found);
        finish();
    } else {
        // Create ArrayList and populate with list of profiles
        ArrayList<String> arrayList = new ArrayList<>(profileList[1].length);
        arrayList.addAll(Arrays.asList(profileList[1]));

        // Create the custom adapter to bind the array to the ListView
        final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, arrayList);

        // Display the ListView
        final ListView listView = findViewById(R.id.listView3);
        listView.setAdapter(adapter);
        listView.setClickable(true);
        listView.setOnItemClickListener((arg0, arg1, position, arg3) -> {
            U.loadProfile(this, profileList[0][position]);
            finish();
        });
    }
}