Java Code Examples for android.widget.ListView.setOnItemClickListener()

The following are Jave code examples for showing how to use setOnItemClickListener() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: QuranAndroid   File: SearchActivity.java   View Source Code Vote up 6 votes
/**
 * Function to init views
 */
private void init() {

    Intent intent = getIntent();
    searchText = intent.getStringExtra(AppConstants.General.SEARCH_TEXT);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(getString(R.string.search));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    resultsInfo = (TextView) findViewById(R.id.textView13);
    ayas = new ArrayList<Aya>();
    adapter = new SearchShowAdapter(this, searchText, ayas);
    searchResults = (ListView) findViewById(R.id.listView3);
    searchResults.setOnItemClickListener(this);
    searchResults.setEmptyView(findViewById(R.id.progressBar3));
    searchResults.setAdapter(adapter);
    new SearchResults().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example 2
Project: Toodoo   File: ToodooNote.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.label_dialog);
    labelList = (ListView) findViewById(R.id.label_list);
    cancel = (Button) findViewById(R.id.cancel);
    // ListView
    SimpleAdapter adapter = new SimpleAdapter(context, getLabelList(),
            R.layout.label_list_item, new String[]{"label_img",
            "label_value"}, new int[]{
            R.id.label_img, R.id.label_value});
    labelList.setAdapter(adapter);
    //ListView
    labelList
            .setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1,
                                        int position, long arg3) {
                    HashMap<String, Object> label = getLabelList().get(position);
                    selectedLabel = (String) label.get("label_value");

                    ToodooOptionsModel ToodooOptionsModel = toodooOptionsList.get(0);
                    ToodooOptionsModel.setOptionValue(selectedLabel);
                    mAdapter.notifyDataSetChanged();
                    labelDialog.dismiss();
                }
            });

    cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            labelDialog.dismiss();
        }
    });
}
 
Example 3
Project: android-apps   File: OtherNewsFragment.java   View Source Code Vote up 6 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_news_list, container, false);
  listView = (ListView) view.findViewById(R.id.list_view);
  listView.setAdapter(adapter = new MyBaseAdapter<Map<String, Object>>(getActivity(), data) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(super.context, convertView, parent, R.layout.list_view_item_news, position);
      Map<String, Object> map = _data.get(position);
      holder.setText(R.id.name, map.get("name").toString());
      holder.setDrawableImage(R.id.logo, (Integer) map.get("logo"));
      return holder.getConvertView();
    }
  });
  listView.setOnItemClickListener(this);
  return view;
}
 
Example 4
Project: RestaurantApp   File: DeskOrdersActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppThemeStaffLogin);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_desk_orders);

    orderHistoryList = new ArrayList<>();
    orderHistoryAdapter = new OrderHistoryAdapter(this, orderHistoryList);

    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().setCustomView(R.layout.custom_actionbar);
    tvActionBar = (TextView)getSupportActionBar().getCustomView().findViewById(R.id.tvActionBar);
    tvActionBar.setText(getResources().getText(R.string.orderHistory));

    lvOrderHistory = (ListView) findViewById(R.id.lvOrderHistory);
    lvOrderHistory.setOnItemClickListener(this);

    orderId = getIntent().getStringExtra("orderId");
    url+=orderId;

    Request request = new Request(this, url, com.android.volley.Request.Method.GET);
    request.requestVolley(this);

}
 
Example 5
Project: odoo-work   File: SelectMembers.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_select_members);

    textNoRecord = (TextView) findViewById(R.id.textEmpty);
    listView = (ListView) findViewById(R.id.list_team_members);
    listView.setOnItemClickListener(this);
    memberList = new ArrayList<>();

    editAddMembers = (EditText) findViewById(R.id.editAddTeamMember);
    editAddMembers.addTextChangedListener(this);

    findViewById(R.id.image_search).setOnClickListener(this);

    try {
        odoo = Odoo.createWithUser(this, OUser.current(this));
    } catch (OdooVersionException e) {
        e.printStackTrace();
    }
}
 
Example 6
Project: Demos   File: ShowUtils.java   View Source Code Vote up 5 votes
/**
 * PopupWindow选择提示框
 *
 * @param activity   当前Activity
 * @param targetView 与提示框关联的控件
 * @param width      提示框宽
 * @param height     提示框高
 * @param list       提示框内容列表
 * @param itemClick  列表点击事件
 */
public static void showPopupWindow(Activity activity, View targetView, int width, int height,
                                   List<String> list, AdapterView.OnItemClickListener itemClick) {
    createPopupWindow(activity, targetView, DensityUtils.dp2px(activity, width),
            DensityUtils.dp2px(activity, height));

    ListView lvOptions = (ListView) view.findViewById(R.id.lv_options);
    popupWindowAdapter = new PopupWindowAdapter(activity, list);
    lvOptions.setAdapter(popupWindowAdapter);
    lvOptions.setOnItemClickListener(itemClick);
}
 
Example 7
Project: eyeRS   File: ItemManagementSettings.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SettingUtilities.onActivityCreateSetTheme(this);
    setContentView(R.layout.activity_item_management_settings);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    listView = (ListView) findViewById(R.id.list_item_mgmt);
    listView.setOnItemClickListener(this);
}
 
Example 8
Project: mapbox-plugins-android   File: OfflineRegionListActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_offline_region_list);

  ListView listView = findViewById(R.id.listView);
  listView.setAdapter(adapter = new OfflineRegionAdapter(this));
  listView.setEmptyView(findViewById(android.R.id.empty));
  listView.setOnItemClickListener(this);
}
 
Example 9
Project: android-apps   File: TencentHuaTiFragment.java   View Source Code Vote up 5 votes
@Override
@Nullable
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_tencent_huati, container, false);

  refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
  listView = (ListView) view.findViewById(R.id.list_view);
  adapter = new MyBaseAdapter<Map<String, Object>>(getActivity(), data) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_tencent_huati, position);
      Map<String, Object> map = data.get(position);
      holder.setText(R.id.title, map.get("n_title").toString())
          .setText(R.id.desc, map.get("n_describe").toString())
          .setText(R.id.author, map.get("n_use_user").toString())
          .setText(R.id.time, FormatUtil.getRelativeTimeSpanString(
              FormatUtil.string2Date(map.get("n_pushtime").toString(), FormatUtil.DATETIME)
          ));
      holder.setNetImage(R.id.thumbnails, map.get("n_pic").toString());
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(getActivity(), listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);
  refreshLayout.setRefreshing(true);

  return view;
}
 
Example 10
Project: HtmlNative   File: ExampleListActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
        mAssetFileList = filterHtmlFile(AssetsUtils.allFiles(this)).toArray();
        ListView listView = new ListView(this);
        ArrayAdapter<Object> arrayAdapter = new ArrayAdapter<>(this, R.layout
                .example_list_item, R.id.example_list_title, mAssetFileList);
        listView.setAdapter(arrayAdapter);
        listView.setOnItemClickListener(this);
        setContentView(listView);
    } catch (IOException e) {
    }
}
 
Example 11
Project: bluewatcher   File: BlueWatcherActivity.java   View Source Code Vote up 5 votes
private void initializeConfigurationOptions() {
	listView = (ListView) findViewById(R.id.list_config_view);

	ArrayAdapter<ConfigurationOption> adapter = new ArrayAdapter<ConfigurationOption>(this.getBaseContext(), android.R.layout.simple_list_item_1);
	adapter.add(new ConfigurationOption(NotificationsActivity.class, getString(R.string.notifications_service)));
	adapter.add(new ConfigurationOption(ControlModesActivity.class, getString(R.string.phone_control_menu_text)));
	adapter.add(new ConfigurationOption(PhoneFinderConfigActivity.class, getString(R.string.phone_finder_service), servicesContainer));
	adapter.add(new ConfigurationOption(TimeConfigActivity.class, getString(R.string.time_sync_service)));
	adapter.add(new ConfigurationOption(AvailableServicesActivity.class, getString(R.string.show_available_services_text), servicesContainer));
	adapter.add(new ConfigurationOption(SettingsActivity.class, getString(R.string.bluewatcher_settings)));
	listView.setAdapter(adapter);
	listView.setOnItemClickListener(new OnConfigurationOptionSelected(this, listView));
}
 
Example 12
Project: android-apps   File: TencentMilFragment.java   View Source Code Vote up 5 votes
@Override
@Nullable
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_tencent_mil, container, false);

  refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
  listView = (ListView) view.findViewById(R.id.list_view);
  adapter = new MyBaseAdapter<Map<String, Object>>(getActivity(), data) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_tencent_news, position);
      Map<String, Object> map = data.get(position);
      holder.setText(R.id.title, map.get("title").toString())
          .setText(R.id.abstract_content, map.get("abstract").toString())
          .setText(R.id.time, FormatUtil.getRelativeTimeSpanString(
              new Date((long) (((double) map.get("timestamp")) * 1000))
          ));
      holder.setNetImage(R.id.thumbnails, ((List) map.get("thumbnails_qqnews")).get(0).toString());
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(getActivity(), listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);
  refreshLayout.setRefreshing(true);

  return view;
}
 
Example 13
Project: sample-lowpan   File: LowpanScanActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lowpan_scan);

    mScanButton = findViewById(R.id.scanButton);
    mScanButton.setOnClickListener((view) -> beginScan());

    Button provisionButton = findViewById(R.id.provisionButton);
    provisionButton.setOnClickListener(view -> createNewNetwork());

    Button leaveButton = findViewById(R.id.leaveButton);
    leaveButton.setOnClickListener(view -> leaveNetwork());

    ListView beaconsView = findViewById(R.id.beacons);
    beaconsView.setOnItemClickListener(this);
    mBeaconsAdapter = new LowpanBeaconAdapter(this);
    beaconsView.setAdapter(mBeaconsAdapter);

    mInterfaceStatus = findViewById(R.id.interfaceStatus);
    mNetworkStatus = findViewById(R.id.networkStatus);

    try {
        mLowpanManager.registerCallback(mInterfaceCallback);
    } catch (LowpanException e) {
        Log.e(TAG, "Unable to attach LoWPAN callback");
    }
}
 
Example 14
Project: TYT   File: TitlePopup.java   View Source Code Vote up 5 votes
/**
 * 初始化弹窗列表
 */
private void initUI() {
    mListView = (ListView) getContentView().findViewById(R.id.title_list);

    mListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
            //点击子类项后,弹窗消失
            dismiss();

            if (mItemOnClickListener != null)
                mItemOnClickListener.onItemClick(mActionItems.get(index), index);
        }
    });
}
 
Example 15
Project: sctalk   File: InternalFragment.java   View Source Code Vote up 5 votes
private void initRes() {
    // 设置顶部标题栏
    setTopTitle(getActivity().getString(R.string.main_innernet));
    internalListView = (ListView)curView.findViewById(R.id.internalListView);
    internalListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            String url = mAdapter.getItem(i).getItemUrl();
            Intent intent=new Intent(InternalFragment.this.getActivity(),WebViewFragmentActivity.class);
            intent.putExtra(IntentConstant.WEBVIEW_URL, url);
            startActivity(intent);
        }
    });
}
 
Example 16
Project: UnversityFinance   File: SimilarProjectNavigationActivity.java   View Source Code Vote up 5 votes
private void initView() {
    mActionBarTitle.setText(R.string.title_project_list);

    mListView = (ListView) findViewById(R.id.listview_similar_pj_navigation);
    mListView.setOnItemClickListener(this);
    TitleOnlyItemAdapter adapter = new TitleOnlyItemAdapter(mProjectList, this);
    mListView.setAdapter(adapter);
}
 
Example 17
Project: PrismatikRemote   File: Profiles.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    mDrawerLayout.addView(inflater.inflate(R.layout.activity_profiles, null));

    profilesListView = (ListView) findViewById(R.id.profilesListView);
    ArrayAdapter<String> itemsAdapter =
            new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, RemoteState.getInstance().getProfiles()) {
                public View getView(int position, View convertView, ViewGroup parent) {
                    super.getView(position, convertView, parent);
                    if (convertView == null) {
                        convertView = super.getView(position, convertView, parent);
                    }
                    if ( RemoteState.getInstance().getProfiles().indexOf(RemoteState.getInstance().getProfile()) == position) {
                        convertView.setBackgroundColor(Color.LTGRAY);
                    }else{
                        convertView.setBackgroundColor(0);;
                    }

                    return convertView;
                }
            };
    profilesListView.setAdapter(itemsAdapter);
    profilesListView.setOnItemClickListener(this);

    setSelection();
}
 
Example 18
Project: chromium-for-android-56-debug-video   File: ConfirmImportantSitesDialogFragment.java   View Source Code Vote up 4 votes
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null) {
        // The important domains and favicon URLs aren't currently saved, so if this dialog
        // is recreated from a saved instance they will be null. This method must return a
        // valid dialog, so these two array's are initialized, then the dialog is dismissed.
        // TODO(dmurph): save mImportantDomains and mFaviconURLs so that they can be restored
        // from a savedInstanceState and the dialog can be properly recreated rather than
        // dismissed.
        mImportantDomains = new String[0];
        mFaviconURLs = new String[0];
        dismiss();
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager =
            ((ActivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(
            activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent data = new Intent();
                List<String> deselectedDomains = new ArrayList<>();
                List<Integer> deselectedDomainReasons = new ArrayList<>();
                List<String> ignoredDomains = new ArrayList<>();
                List<Integer> ignoredDomainReasons = new ArrayList<>();
                for (Entry<String, Boolean> entry : mCheckedState.entrySet()) {
                    Integer reason = mImportantDomainsReasons.get(entry.getKey());
                    if (entry.getValue()) {
                        ignoredDomains.add(entry.getKey());
                        ignoredDomainReasons.add(reason);
                    } else {
                        deselectedDomains.add(entry.getKey());
                        deselectedDomainReasons.add(reason);
                    }
                }
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains.toArray(new String[0]));
                data.putExtra(
                        DESELECTED_DOMAIN_REASONS_TAG, toIntArray(deselectedDomainReasons));
                data.putExtra(IGNORED_DOMAINS_TAG, ignoredDomains.toArray(new String[0]));
                data.putExtra(IGNORED_DOMAIN_REASONS_TAG, toIntArray(ignoredDomainReasons));
                getTargetFragment().onActivityResult(
                        getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(),
                        Activity.RESULT_CANCELED, getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater().inflate(
            R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder =
            new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
                    .setTitle(R.string.storage_clear_site_storage_title)
                    .setPositiveButton(R.string.clear_browsing_data_important_dialog_button,
                            listener)
                    .setNegativeButton(R.string.cancel, listener)
                    .setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}
 
Example 19
Project: android-apps   File: OSChinaProjectFragment.java   View Source Code Vote up 4 votes
@Override
@Nullable
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_oschina, container, false);

  refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
  listView = (ListView) view.findViewById(R.id.list_view);
  adapter = new MyBaseAdapter<Map<String, Object>>(getActivity(), data) {
    List<Integer> positions = new ArrayList<>();

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_osc, position);
      Map<String, Object> map = data.get(position);
      holder.setText(R.id.title, map.get("title").toString())
          .setText(R.id.desc, map.get("desc").toString())
          .setText(R.id.replyCount, map.get("replyCount").toString())
          .setText(R.id.time, map.get("time").toString());
      holder.setNetImage(R.id.avatar, map.get("avatar").toString());
      holder.getView(R.id.readFirstImg).setVisibility(View.GONE);
      if (map.get("readFirstImg") != null) {
        positions.add(holder.getPosition());
      } else {
        positions.remove((Integer) holder.getPosition());
      }
      if (positions.contains(holder.getPosition())) {
        holder.setNetImage(R.id.readFirstImg, map.get("readFirstImg").toString());
        holder.getView(R.id.readFirstImg).setVisibility(View.VISIBLE);
      }
      return holder.getConvertView();
    }
  };
  listView.setAdapter(adapter);
  loadMoreFooter = new LoadMoreFooter(getActivity(), listView, this);

  refreshLayout.setOnRefreshListener(this);
  listView.setOnItemClickListener(this);

  refreshLayout.setRefreshing(true);
  return view;
}
 
Example 20
Project: GitHub   File: RealmMainActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);

    setTitle("Realm.io Examples");

    ArrayList<ContentItem> objects = new ArrayList<ContentItem>();

    objects.add(new ContentItem("Line Chart", "Creating a LineChart with Realm.io database"));
    objects.add(new ContentItem("Bar Chart",
            "Creating a BarChart with Realm.io database"));
    objects.add(new ContentItem("Horizontal Bar Chart",
            "Creating a HorizontalBarChart with Realm.io database"));
    objects.add(new ContentItem("Scatter Chart",
            "Creating a ScatterChart with Realm.io database"));
    objects.add(new ContentItem("Candle Stick Chart", "Creating a CandleStickChart with Realm.io database"));
    objects.add(new ContentItem("Bubble Chart", "Creating a BubbleChart with Realm.io database"));
    objects.add(new ContentItem("Pie Chart", "Creating a PieChart with Realm.io database"));
    objects.add(new ContentItem("Radar Chart", "Creating a RadarChart with Realm.io database"));
    objects.add(new ContentItem("Realm Wiki", "This is the code related to the wiki entry about realm.io on the MPAndroidChart github page."));

    MyAdapter adapter = new MyAdapter(this, objects);

    ListView lv = (ListView) findViewById(R.id.listView1);
    lv.setAdapter(adapter);

    lv.setOnItemClickListener(this);

    Realm.init(this);

    // Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
    RealmConfiguration realmConfig = new RealmConfiguration.Builder().build();
    Realm.setDefaultConfiguration(realmConfig);

    Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    realm.deleteAll();
    realm.commitTransaction();
}