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

The following examples show how to use android.widget.ListView#setOnItemLongClickListener() . 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: FileAcitvity.java    From Jreader with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 初始化view
 */
private void initView() {

    listView = (ListView) findViewById(R.id.local_File_drawer);
    adapter = new FileAdapter(this, listFile, isSelected);
    listView.setAdapter(adapter);
    map = new HashMap<String, String>();
    listView.setOnItemClickListener(new DrawerItemClickListener());
    listView.setOnItemLongClickListener(new DrawerItemClickListener());//
    returnBtn = (ImageButton) findViewById(R.id.local_File_return_btn);
    titleView = (TextView) findViewById(R.id.local_File_title);
    chooseAllButton = (Button) findViewById(R.id.choose_all);
    deleteButton = (Button) findViewById(R.id.delete);
    addfileButton = (Button) findViewById(R.id.add_file);

    searchData(root.getAbsolutePath());
    addPath(root.getAbsolutePath());

}
 
Example 2
Source File: AlertList.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alert_list);
    mContext = getApplicationContext();
    listViewLow = (ListView) findViewById(R.id.listView_low);
    listViewHigh = (ListView) findViewById(R.id.listView_high);
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    FillLists();
    anim = AnimationUtils.loadAnimation(this, R.anim.fade_anim);
    listViewLow.setOnItemLongClickListener(new AlertsOnItemLongClickListener());
    listViewHigh.setOnItemLongClickListener(new AlertsOnItemLongClickListener());
}
 
Example 3
Source File: DocumentsActivity.java    From GreenDamFileExploere with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_documents);
    mViewNothing = findViewById(R.id.nothing);
    
    FileUtils.checkFile(mDocs);
    Collections.sort(mDocs, new SimpleFileComparator());

    mListView = (ListView) findViewById(R.id.mDocListView);
    mAdapter = new DocAndZipsAdapter(this, mDocs);
    mListView.setAdapter(mAdapter);

    mListView.setOnItemClickListener(this);
    mListView.setOnItemLongClickListener(this);
    mThread.start();
}
 
Example 4
Source File: TopicsFragment.java    From OPFPush with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull final LayoutInflater inflater,
                         @Nullable final ViewGroup container,
                         @Nullable final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_topics, container, false);

    infoText = (TextView) view.findViewById(R.id.topic_info);
    topicEditText = (EditText) view.findViewById(R.id.topic_input);
    subscribeButton = (Button) view.findViewById(R.id.subscribe_topic_button);
    topicsListView = (ListView) view.findViewById(R.id.topics_list);
    progressBar = (ProgressBar) view.findViewById(R.id.topic_progress_bar);

    subscribeButton.setOnClickListener(new OnSubscribeClickListener());
    topicEditText.addTextChangedListener(new TopicTextWatcher());
    topicsListView.setAdapter(adapter);
    topicsListView.setOnItemLongClickListener(new OnTopicItemLongLickListener());

    registerReceiver();
    initViews();

    return view;
}
 
Example 5
Source File: LogFragment.java    From bitmask_android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ListView lv = getListView();

    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view,
                                       int position, long id) {
            ClipboardManager clipboard = (ClipboardManager)
                    getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Log Entry", ((TextView) view).getText());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(getActivity(), R.string.copied_entry, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}
 
Example 6
Source File: ContactFragment.java    From LoveTalkClient with Apache License 2.0 6 votes vote down vote up
private void initListView() {
	friendsList = (ListView) getView().findViewById(R.id.list_friends);
	LayoutInflater mInflater = LayoutInflater.from(context);
	RelativeLayout headView = (RelativeLayout) mInflater.inflate(
			R.layout.contact_include_new_friend, null);
	msgTipsView = (ImageView) headView.findViewById(R.id.iv_msg_tips);
	newFriendLayout = (LinearLayout) headView.findViewById(R.id.layout_new);


	newFriendLayout.setOnClickListener(this);

	friendsList.addHeaderView(headView);
	userAdapter = new UserFriendAdapter(getActivity(), friends);
	friendsList.setAdapter(userAdapter);
	friendsList.setOnItemClickListener(this);
	friendsList.setOnItemLongClickListener(this);
	friendsList.setOnTouchListener(new OnTouchListener() {

		@Override
		public boolean onTouch(View v, MotionEvent event) {
			Utils.hideSoftInputView(getActivity());
			return false;
		}
	});
}
 
Example 7
Source File: FriendActivity.java    From Conquer with Apache License 2.0 5 votes vote down vote up
private void initListView() {
	list_friends = (ListView) findViewById(R.id.list_friends);
	RelativeLayout headView = (RelativeLayout) View.inflate(context, R.layout.layout_new_friend, null);
	iv_msg_tips = (ImageView) headView.findViewById(R.id.iv_msg_tips);
	headView.findViewById(R.id.layout_new).setOnClickListener(this);
	headView.findViewById(R.id.layout_near).setOnClickListener(this);
	headView.findViewById(R.id.layout_add).setOnClickListener(this);
	list_friends.addHeaderView(headView);
	userAdapter = new UserFriendAdapter(context, friends);
	list_friends.setAdapter(userAdapter);
	list_friends.setOnItemClickListener(this);
	list_friends.setOnItemLongClickListener(this);
}
 
Example 8
Source File: MainActivity.java    From sim-password-manager with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.activity_main);

    messageText = (TextView) findViewById(R.id.message_text);
    nameText = (EditText) findViewById(R.id.name_text);
    passwordText = (EditText) findViewById(R.id.password_text);

    initilizeButton = (Button) findViewById(R.id.init_pm_button);
    initilizeButton.setOnClickListener(this);
    initilizeButton.setVisibility(View.GONE);
    initilizeButton.setEnabled(false);

    passwordsList = (ListView) findViewById(R.id.passwords_list);
    passwordsList.setOnItemLongClickListener(this);
    passwordsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            nameText.setText(null);
            passwordText.setText(null);
        }

    };

    db = PasswordDb.getInstance(this);
}
 
Example 9
Source File: CloudPageInboxActivity.java    From LearningAppAndroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cloudpage_inbox_layout);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setTitle(getResources().getString(R.string.app_name));
    }

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    RadioGroup filterRadioGroup;
    final ListView cloudPageListView;

    filterRadioGroup = findViewById(R.id.filterRadioGroup);
    cloudPageListView = findViewById(R.id.cloudPageListView);

    filterRadioGroup.setOnCheckedChangeListener(radioChangedListener);

    cloudPageListView.setOnItemClickListener(cloudPageItemClickListener);
    cloudPageListView.setOnItemLongClickListener(cloudPageItemDeleteListener);

    MarketingCloudSdk.requestSdk(new MarketingCloudSdk.WhenReadyListener() {
        @Override
        public void ready(@NonNull MarketingCloudSdk marketingCloudSdk) {
            marketingCloudSdk.getAnalyticsManager().trackPageView("data://CloudPageInbox", "Cloud Page Inbox index view displayed", null, null);
            cloudPageListAdapter = new MyCloudPageListAdapter(marketingCloudSdk);
            cloudPageListView.setAdapter(cloudPageListAdapter);
        }
    });

}
 
Example 10
Source File: DownloadActivity.java    From AnimeTaste with MIT License 5 votes vote down vote up
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
    mBinder = (DownloadService.DownloadServiceBinder)service;
    isConnected = true;
    mDownloadList = (ListView)findViewById(R.id.download_list);
    mAdapter = (DownloadAdapter)mBinder.getMissionAdapter();
    mDownloadList.setAdapter(mAdapter);
    mDownloadList.setOnItemClickListener(DownloadActivity.this);
    mDownloadList.setOnItemLongClickListener(DownloadActivity.this);
}
 
Example 11
Source File: AlertList.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = getApplicationContext();
    listViewLow = (ListView) findViewById(R.id.listView_low);
    listViewHigh = (ListView) findViewById(R.id.listView_high);
    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    FillLists();
    listViewLow.setOnItemLongClickListener(new AlertsOnItemLongClickListener());
    listViewHigh.setOnItemLongClickListener(new AlertsOnItemLongClickListener());
}
 
Example 12
Source File: ChatsFragment.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater,
                         final ViewGroup container, final Bundle savedInstanceState) {
    init(container, savedInstanceState);
    setHasOptionsMenu(true);
    setActionBarTitle(R.string.chat_fragment_title);
    final View view = inflater
            .inflate(R.layout.fragment_chats, container, false);
    mChatsListView = (ListView) view.findViewById(R.id.list_chats);
    mChatsAdapter = new ChatsAdapter(getActivity(), null);
    mChatsListView.setAdapter(mChatsAdapter);
    mChatsListView.setOnItemClickListener(this);
    mChatsListView.setOnItemLongClickListener(this);
    mChatDialogFragment = (SingleChoiceDialogFragment) getFragmentManager()
            .findFragmentByTag(FragmentTags.DIALOG_CHAT_LONGCLICK);

    if (savedInstanceState == null) {

        final Bundle args = getArguments();

        if (args != null) {
            mShouldLoadChat = args.getBoolean(Keys.LOAD_CHAT);

            if (mShouldLoadChat) {
                mUserIdToLoad = args.getString(Keys.USER_ID);
                mPreloadedChatMessage = args.getString(Keys.CHAT_MESSAGE);
            }

            if (TextUtils.isEmpty(mUserIdToLoad)) {
                mShouldLoadChat = false;
                mPreloadedChatMessage = null;
            }
        }
    }
    getLoaderManager().restartLoader(Loaders.ALL_CHATS, null, this);
    return view;
}
 
Example 13
Source File: ConnectionsFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    final Resources res = getActivity().getResources();

    fab = (FloatingActionButton)view.findViewById(R.id.fab);
    fab.setOnClickListener(this);
    if(isTelevision()){
        fab.setVisibility(View.GONE);
    }

    mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);
    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);
    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    if(isTelevision()) {
        mListView.setOnItemLongClickListener(mItemLongClickListener);
    }
    fab.attachToListView(mListView);

    // Indent our list divider to align with text
    final Drawable divider = mListView.getDivider();
    final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
    final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
    if (insetLeft) {
        mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
    } else {
        mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
    }
}
 
Example 14
Source File: FriendHistoryFragment.java    From repay-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
	super.onActivityCreated(savedInstanceState);

	mList = (ListView) getView().findViewById(R.id.fragment_debtHistory_list);
	mList.setOnItemLongClickListener(this);
	mNoDebtsMsg = (TextView) getView().findViewById(R.id.fragment_debtHistory_noDebts);
	mProgressBar = (ProgressBar) getView().findViewById(R.id.fragment_debtHistory_progress);
	mProgressBar.setVisibility(ProgressBar.GONE);
}
 
Example 15
Source File: DialogUnit.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
private void display(DialogProvider dialogProvider) {
	Context context = uiManager.getContext();
	FrameLayout content = new FrameLayout(context);
	ListView listView = new ListView(context);
	content.addView(listView, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
	DialogPostsAdapter adapter = new DialogPostsAdapter(dialogProvider, listView);
	listView.setOnItemClickListener(adapter);
	listView.setOnItemLongClickListener(adapter);
	ScrollListenerComposite.obtain(listView).add(new BusyScrollListener(adapter));
	listView.setAdapter(adapter);
	listView.setId(android.R.id.list);
	listView.setDivider(ResourceUtils.getDrawable(context, R.attr.postsDivider, 0));
	final DialogHolder holder = new DialogHolder(adapter, dialogProvider, content, listView);
	uiManager.observable().register(holder);
	ImageLoader.getInstance().observable().register(holder);
	listView.setTag(holder);
	content.setTag(holder);
	dialogStack.push(content);
	dialogProvider.setStateListener((state) -> {
		switch (state) {
			case STATE_LIST: {
				holder.setShowLoading(false);
				holder.requestUpdate();
				return true;
			}
			case STATE_LOADING: {
				holder.setShowLoading(true);
				return true;
			}
			case STATE_ERROR: {
				if (!holder.cancelled) {
					dialogStack.pop();
					return true;
				}
				return false;
			}
		}
		return false;
	});
}
 
Example 16
Source File: TitlesFragment.java    From androidtestdebug with MIT License 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    //Current position should survive screen rotations.
    if (savedInstanceState != null) {
        mCategory = savedInstanceState.getInt("category");
        mCurPosition = savedInstanceState.getInt("listPosition");
    }

    populateTitles(mCategory);
    ListView lv = getListView();
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            final String title = (String) ((TextView) v).getText();

            // Set up clip data with the category||entry_id format.
            final String textData = String.format("%d||%d", mCategory, pos);
            ClipData data = ClipData.newPlainText(title, textData);
            v.startDrag(data, new MyDragShadowBuilder(v), null, 0);
            return true;
        }
    });

    selectPosition(mCurPosition);
}
 
Example 17
Source File: MActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.acmain);
    tv_content = (TextView) findViewById(R.id.tv_content);
    listview = (ListView) findViewById(R.id.listview);
    dataList = new ArrayList<Map<String, Object>>();

    Button addNote = (Button) findViewById(R.id.btn_editnote);
    mContext = this;
    addNote.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            noteEdit.ENTER_STATE = 0;
            Intent intent = new Intent(mContext, noteEdit.class);
            Bundle bundle = new Bundle();
            bundle.putString("info", "");
            intent.putExtras(bundle);
            startActivityForResult(intent, 1);
        }
    });
    NotesDB DB = new NotesDB(this);
    dbread = DB.getReadableDatabase();
    // 清空数据库中表的内容
    //dbread.execSQL("delete from note");
    RefreshNotesList();

    listview.setOnItemClickListener(this);
    listview.setOnItemLongClickListener(this);
    //listview.setOnScrollListener(this);
}
 
Example 18
Source File: DeskBasketActivity.java    From RestaurantApp with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppThemeStaffLogin);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_desk_basket);

    lvBasket= (ListView) findViewById(R.id.lvBasket);
    lvBasket.setOnItemLongClickListener(this);
    lvBasket.setOnItemClickListener(this);
    productList = new ArrayList<>();

    btnOrderVerify = (FlatButton) findViewById(R.id.btnOrderVerify);
    btnOrderVerify.setOnClickListener(this);

    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().getString(R.string.staffDeskBasketHeader));
    tvActionBar.setTextAppearance(this, android.R.style.TextAppearance_Large);
    tvActionBar.setTextColor(Color.WHITE);

    orderId = getIntent().getIntExtra("orderId",-1);
    status = getIntent().getIntExtra("status",-1);
    url+=orderId;

    if (status == 0){
        btnOrderVerify.setBackgroundColor(getResources().getColor(R.color.status0));
        btnOrderVerify.setText("SİPARİŞ YOK");
        btnOrderVerify.setClickable(false);
    }else if (status == 1){
        btnOrderVerify.setBackgroundColor(getResources().getColor(R.color.status1));
        btnOrderVerify.setText("SİPARİŞİ ONAYLA");
        btnOrderVerify.setClickable(true);
    }else{
        btnOrderVerify.setBackgroundColor(getResources().getColor(R.color.status2));
        btnOrderVerify.setText("SİPARİŞ ONAYLANMIŞ");
        btnOrderVerify.setClickable(false);
    }

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

}
 
Example 19
Source File: ChoiceDialog.java    From currency with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    // Get preferences
    SharedPreferences preferences =
        PreferenceManager.getDefaultSharedPreferences(this);

    boolean theme = preferences.getBoolean(Main.PREF_DARK, true);

    if (!theme)
        setTheme(R.style.DialogLightTheme);

    setContentView(R.layout.choose);

    // Find views
    ListView listView = findViewById(R.id.list);

    Button cancel = findViewById(R.id.cancel);
    clear = findViewById(R.id.clear);
    select = findViewById(R.id.select);

    // Set the listeners
    if (listView != null)
    {
        listView.setOnItemClickListener(this);
        listView.setOnItemLongClickListener(this);
    }

    if (cancel != null)
        cancel.setOnClickListener(this);

    if (clear != null)
        clear.setOnClickListener(this);

    if (select != null)
        select.setOnClickListener(this);

    selectList = new ArrayList<>();

    // Populate the lists
    List<Integer> flagList = Arrays.asList(Main.CURRENCY_FLAGS);
    List<Integer> longNameList = Arrays.asList(Main.CURRENCY_LONGNAMES);
    List<String> nameList = Arrays.asList(Main.CURRENCY_NAMES);

    // Create the adapter
    adapter = new ChoiceAdapter(this, R.layout.choice, flagList,
                                nameList, longNameList, selectList);

    // Set the adapter
    if (listView != null)
        listView.setAdapter(adapter);
}
 
Example 20
Source File: GLDemoActivity.java    From java6-android-gldemos with Apache License 2.0 2 votes vote down vote up
protected void onCreate(Bundle savedInstanceState)
{
   super.onCreate(savedInstanceState);

   setContentView(R.layout.list_activity_layout);

   Resources resources = getResources();

   Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
   toolbar.setLogo(R.drawable.ic_launcher);
   toolbar.setTitle(R.string.app_title);
   toolbar.setContentInsetsAbsolute(0, 0);

   setSupportActionBar(toolbar);

   deviceGLVersion = AndroidGLESUtil.getGLVersion(this);

   adapter = new GLHeaderAdapter(this);

   adapter.addSectionHeaderItem(resources.getString(R.string.header_gles_3_0));

   adapter.addItem(GLSLInvert.class, XeGLES3.GLES3_0,
    "https://github.com/typhonrt/modern-java6-android-gldemos/wiki/gles30demo-glslinvert");

   adapter.addItem(GLSLKuwahara.class, XeGLES3.GLES3_0,
    "https://github.com/typhonrt/modern-java6-android-gldemos/wiki/gles30demo-glslkuwahara");

   adapter.addItem(GLSLKuwaharaFBO.class, XeGLES3.GLES3_0,
    "https://github.com/typhonrt/modern-java6-android-gldemos/wiki/gles30demo-glslkuwaharafbo");

   adapter.addSectionHeaderItem(resources.getString(R.string.header_gles_3_1));

   adapter.addItem(ComputeBasicRayTrace.class, XeGLES3.GLES3_1,
    "https://github.com/typhonrt/modern-java6-android-gldemos/wiki/gles31demo-computebasicraytrace");

   adapter.addItem(ComputeInvert.class, XeGLES3.GLES3_1,
    "https://github.com/typhonrt/modern-java6-android-gldemos/wiki/gles31demo-computeinvert");

   adapter.addItem(ComputeInvertSampler.class, XeGLES3.GLES3_1,
    "https://github.com/typhonrt/modern-java6-android-gldemos/wiki/gles31demo-computeinvertsampler");

   ListView listView = (ListView)findViewById(R.id.main_listview);

   listView.setAdapter(adapter);
   listView.setOnItemClickListener(this);
   listView.setOnItemLongClickListener(this);
}