Android ListView with fast scroll and alphabetical section index

后端 未结 3 1484
感情败类
感情败类 2020-12-05 19:49

How to add testview when touching a letter on right alphabet panel as shown in images? Could you please help me? Below is my code.

In details, I am looking for an e

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 20:26

    If you want to show the alphabet clicked as a Toast (a custom toast like the one shown in the image) use this:

    view.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            LayoutInflater inflater = getLayoutInflater();
            View layout = inflater.inflate(R.layout.toast_custom_layout,
            (ViewGroup) findViewById(R.id.toast_layout_root));
            Toast toast = new Toast(getApplicationContext());
            toast.setGravity(Gravity.BOTTOM, 0, 0);
            // to position the Toast on the screen
            toast.setDuration(Toast.LENGTH_LONG);
            // to set the duration, the toast should appear
            toast.setView(layout);
            // a custom layout for the toast
            toast.show();
        }
    });
    

    and your toast_custom_layout.xml will be a 100 x 100 layout with large text size

提交回复
热议问题