Example usage for android.widget ListView setDividerHeight

List of usage examples for android.widget ListView setDividerHeight

Introduction

In this page you can find the example usage for android.widget ListView setDividerHeight.

Prototype

public void setDividerHeight(int height) 

Source Link

Document

Sets the height of the divider that will be drawn between each item in the list.

Usage

From source file:com.ehelp.home.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/*from www . j av  a2s. co  m*/
    //fl.setBackgroundColor(0x666666);
    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setGravity(Gravity.TOP);
    System.out.println(position);
    if (position == 0) {
        fl.removeAllViews();
        mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;
        mMapView = new MapView(getActivity());
        mMapView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));
        fl.addView(mMapView);
        mBaiduMap = mMapView.getMap();
        // ??
        mBaiduMap.setMyLocationEnabled(true);
        // ??
        mLocClient = new LocationClient(getActivity());
        mLocClient.registerLocationListener(myListener);
        LocationClientOption option = new LocationClientOption();
        option.setOpenGps(true);// gps
        option.setCoorType("bd09ll"); // ??
        option.setScanSpan(1000);
        mLocClient.setLocOption(option);
        mLocClient.start();
        int count = mMapView.getChildCount();
        for (int i = 0; i < count; i++) {
            View child = mMapView.getChildAt(i);
            if (child instanceof ZoomControls || child instanceof ImageView) {
                child.setVisibility(View.INVISIBLE);
            }
        }
        setLocation();
    } else if (position == 1) {
        fl.removeAllViews();
        ListView queList = new ListView(getActivity());
        queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
        HomeAdapter que = new HomeAdapter(getActivity(), user_id, 2, eventCache);
        queList.setAdapter(que);
        queList.setDividerHeight(20);
        fl.addView(queList);

        events = que.getEvent();

        //?
        queList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
                Intent intent = new Intent(getActivity(), recievesos_map.class);
                int eventid = events.get(index).getEventId();
                intent.putExtra(EXTRA_MESSAGE, eventid);
                startActivity(intent);
            }
        });
    } else if (position == 2) {
        fl.removeAllViews();
        ListView queList = new ListView(getActivity());
        queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
        //queList.setBackgroundColor(0x666666);
        //queList.setAlpha(125);
        queList.setDividerHeight(20);
        HomeAdapter que = new HomeAdapter(getActivity(), user_id, 1, eventCache);
        queList.setAdapter(que);
        fl.addView(queList);

        events = que.getEvent();

        //?
        queList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
                Intent intent = new Intent(getActivity(), recieve_help_ans_map.class);
                intent.putExtra(EXTRA_MESSAGE, events.get(index));
                startActivity(intent);
            }
        });
    } else if (position == 3) {
        fl.removeAllViews();
        ListView queList = new ListView(getActivity());
        queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
        HomeAdapter que = new HomeAdapter(getActivity(), user_id, 0, eventCache);
        queList.setAdapter(que);
        queList.setDividerHeight(20);
        fl.addView(queList);

        events = que.getEvent();

        //?
        queList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
                Intent intent = new Intent(getActivity(), QuestionDetail.class);
                intent.putExtra("qusetiondatail", events.get(index));
                startActivity(intent);
            }
        });
    }
    return fl;
}

From source file:org.telegram.ui.SessionsActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("SessionsTitle", R.string.SessionsTitle));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//from w w  w. ja  v  a  2s .  c  o m
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

    emptyLayout = new LinearLayout(context);
    emptyLayout.setOrientation(LinearLayout.VERTICAL);
    emptyLayout.setGravity(Gravity.CENTER);
    //emptyLayout.setBackgroundResource(R.drawable.greydivider_bottom);
    emptyLayout.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
            AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight()));

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.devices);
    emptyLayout.addView(imageView);
    LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    imageView.setLayoutParams(layoutParams2);

    TextView textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.disabled_text) /*0xff8a8a8a*/);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setText(LocaleController.getString("NoOtherSessions", R.string.NoOtherSessions));
    emptyLayout.addView(textView);
    layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
    layoutParams2.topMargin = AndroidUtilities.dp(16);
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER;
    textView.setLayoutParams(layoutParams2);

    textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.disabled_text) /*0xff8a8a8a*/);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    textView.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0);
    textView.setText(LocaleController.getString("NoOtherSessionsInfo", R.string.NoOtherSessionsInfo));
    emptyLayout.addView(textView);
    layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
    layoutParams2.topMargin = AndroidUtilities.dp(14);
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER;
    textView.setLayoutParams(layoutParams2);

    FrameLayout progressView = new FrameLayout(context);
    frameLayout.addView(progressView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    progressView.setLayoutParams(layoutParams);
    progressView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);

    ListView listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDrawSelectorOnTop(true);
    listView.setEmptyView(progressView);
    frameLayout.addView(listView);
    layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP;
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
            if (i == terminateAllSessionsRow) {
                if (getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setMessage(
                        LocaleController.getString("AreYouSureSessions", R.string.AreYouSureSessions));
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                TLRPC.TL_auth_resetAuthorizations req = new TLRPC.TL_auth_resetAuthorizations();
                                ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                                    @Override
                                    public void run(final TLObject response, final TLRPC.TL_error error) {
                                        AndroidUtilities.runOnUIThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                if (getParentActivity() == null) {
                                                    return;
                                                }
                                                if (error == null && response instanceof TLRPC.TL_boolTrue) {
                                                    Toast toast = Toast.makeText(getParentActivity(),
                                                            LocaleController.getString("TerminateAllSessions",
                                                                    R.string.TerminateAllSessions),
                                                            Toast.LENGTH_SHORT);
                                                    toast.show();
                                                } else {
                                                    Toast toast = Toast
                                                            .makeText(getParentActivity(),
                                                                    LocaleController.getString("UnknownError",
                                                                            R.string.UnknownError),
                                                                    Toast.LENGTH_SHORT);
                                                    toast.show();
                                                }
                                                finishFragment();
                                            }
                                        });
                                        UserConfig.registeredForPush = false;
                                        UserConfig.saveConfig(false);
                                        MessagesController.getInstance().registerForPush(UserConfig.pushString);
                                        ConnectionsManager.getInstance()
                                                .setUserId(UserConfig.getClientUserId());
                                    }
                                });
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i >= otherSessionsStartRow && i < otherSessionsEndRow) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setMessage(LocaleController.getString("TerminateSessionQuestion",
                        R.string.TerminateSessionQuestion));
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int option) {
                                final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
                                progressDialog
                                        .setMessage(LocaleController.getString("Loading", R.string.Loading));
                                progressDialog.setCanceledOnTouchOutside(false);
                                progressDialog.setCancelable(false);
                                progressDialog.show();

                                final TLRPC.TL_authorization authorization = sessions
                                        .get(i - otherSessionsStartRow);
                                TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization();
                                req.hash = authorization.hash;
                                ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                                    @Override
                                    public void run(final TLObject response, final TLRPC.TL_error error) {
                                        AndroidUtilities.runOnUIThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                try {
                                                    progressDialog.dismiss();
                                                } catch (Exception e) {
                                                    FileLog.e("tmessages", e);
                                                }
                                                if (error == null) {
                                                    sessions.remove(authorization);
                                                    updateRows();
                                                    if (listAdapter != null) {
                                                        listAdapter.notifyDataSetChanged();
                                                    }
                                                }
                                            }
                                        });
                                    }
                                });
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            }
        }
    });

    return fragmentView;
}

From source file:org.telegram.ui.myLocationSettingsActivity.java

@Override
public View createView(LayoutInflater inflater) {
    if (fragmentView == null) {
        actionBar.setBackButtonImage(R.drawable.ic_ab_back);
        actionBar.setAllowOverlayTitle(true);
        actionBar.setTitle("My Places");
        actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
            @Override//from   ww w .  ja v a2  s  .  co  m
            public void onItemClick(int id) {
                if (id == -1) {
                    finishFragment();
                }
            }
        });

        listAdapter = new ListAdapter(getParentActivity());

        fragmentView = new FrameLayout(getParentActivity());
        FrameLayout frameLayout = (FrameLayout) fragmentView;
        frameLayout.setBackgroundColor(0xfff0f0f0);

        ListView listView = new ListView(getParentActivity());
        listView.setDivider(null);
        listView.setDividerHeight(0);
        listView.setVerticalScrollBarEnabled(false);
        listView.setDrawSelectorOnTop(true);
        frameLayout.addView(listView);
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
        layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
        layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
        layoutParams.gravity = Gravity.TOP;
        listView.setLayoutParams(layoutParams);
        listView.setAdapter(listAdapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
                if (i == homeRow) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setTitle("Home");
                    final ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(50, 30);
                    final EditText input = new EditText(getParentActivity());
                    input.setHint("Insert city");
                    input.setLayoutParams(lparams);
                    builder.setView(input);
                    builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            if (input.getText().toString().trim().length() > 0) {
                                String city = input.getText().toString().trim();
                                try {
                                    Bundle locationHome = new getCoordinates().execute(city).get();
                                    String latHome = locationHome.getString("lat");
                                    String lonHome = locationHome.getString("lon");
                                    SharedPreferences sharedPreferences = ApplicationLoader.applicationContext
                                            .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
                                    SharedPreferences.Editor editor = sharedPreferences.edit();
                                    editor.putString("latHome", latHome);
                                    editor.putString("longHome", lonHome);
                                    editor.commit();
                                    Log.i(TAG, "fine! " + lonHome);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                } catch (ExecutionException e) {
                                    e.printStackTrace();
                                }
                            } else {
                                Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT)
                                        .show();
                            }

                        }
                    });
                    builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show();
                        }
                    });
                    showAlertDialog(builder);
                } else if (i == workRow) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setTitle("Work");
                    final EditText input = new EditText(getParentActivity());
                    input.setHint("Insert city");
                    builder.setView(input);
                    builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            if (input.getText().toString().trim().length() > 0) {
                                String city = input.getText().toString().trim();
                                try {
                                    Bundle locationWork = new getCoordinates().execute(city).get();
                                    String latWork = locationWork.getString("lat");
                                    String lonWork = locationWork.getString("lon");
                                    SharedPreferences sharedPreferences = ApplicationLoader.applicationContext
                                            .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
                                    SharedPreferences.Editor editor = sharedPreferences.edit();
                                    editor.putString("latWork", latWork);
                                    editor.putString("longWork", lonWork);
                                    editor.commit();
                                    Log.i(TAG, "fine! " + latWork);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                } catch (ExecutionException e) {
                                    e.printStackTrace();
                                }
                            } else {
                                Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT)
                                        .show();
                            }

                        }
                    });
                    builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show();
                        }
                    });
                    showAlertDialog(builder);
                } else if (i == entertainmentRow) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                    builder.setTitle("Entertainment");
                    final EditText input = new EditText(getParentActivity());
                    input.setHint("Insert city");
                    builder.setView(input);
                    builder.setPositiveButton("confirm", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            if (input.getText().toString().trim().length() > 0) {
                                String city = input.getText().toString().trim();
                                try {
                                    Bundle locationEntertainment = new getCoordinates().execute(city).get();
                                    String latEntertainment = locationEntertainment.getString("lat");
                                    String lonEntertainment = locationEntertainment.getString("lon");
                                    SharedPreferences sharedPreferences = ApplicationLoader.applicationContext
                                            .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
                                    SharedPreferences.Editor editor = sharedPreferences.edit();
                                    editor.putString("latEntertainment", latEntertainment);
                                    editor.putString("longEntertainment", lonEntertainment);
                                    editor.commit();
                                    Log.i(TAG, "fine! " + latEntertainment);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                } catch (ExecutionException e) {
                                    e.printStackTrace();
                                }
                            } else {
                                Toast.makeText(getParentActivity(), "That is empty :(", Toast.LENGTH_SHORT)
                                        .show();
                            }

                        }
                    });
                    builder.setNegativeButton("Why?", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Toast.makeText(getParentActivity(), "To website", Toast.LENGTH_SHORT).show();
                        }
                    });
                    showAlertDialog(builder);
                }
                //TODO find a solution for commuteRow as well!!
            }
        });
    } else {
        ViewGroup parent = (ViewGroup) fragmentView.getParent();
        if (parent != null) {
            parent.removeView(fragmentView);
        }
    }
    return fragmentView;
}

From source file:com.github.mobile.gauges.ui.TrafficListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (gauge != null && gaugeId == null)
        gaugeId = gauge.getId();/* ww  w  .  j av a2  s.  co m*/

    ListView listView = getListView();

    if (getListAdapter() == null) {
        listView.addHeaderView(getLayoutInflater(savedInstanceState).inflate(layout.traffic_graph, null), null,
                false);
        listView.addHeaderView(
                getLayoutInflater(savedInstanceState).inflate(layout.traffic_list_item_labels, null), null,
                false);
    }

    listView.setSelector(android.R.color.transparent);
    listView.setCacheColorHint(getResources().getColor(android.R.color.transparent));
    listView.setDrawSelectorOnTop(false);
    listView.setFastScrollEnabled(true);
    listView.setDividerHeight(0);
}

From source file:org.telegram.ui.PrivacyControlActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    if (isGroup) {
        actionBar.setTitle(LocaleController.getString("GroupsAndChannels", R.string.GroupsAndChannels));
    } else {/*from w w w .ja  v  a2s. com*/
        actionBar.setTitle(LocaleController.getString("PrivacyLastSeen", R.string.PrivacyLastSeen));
    }
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == done_button) {
                if (getParentActivity() == null) {
                    return;
                }

                if (currentType != 0 && !isGroup) {
                    final SharedPreferences preferences = ApplicationLoader.applicationContext
                            .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
                    boolean showed = preferences.getBoolean("privacyAlertShowed", false);
                    if (!showed) {
                        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                        if (isGroup) {
                            builder.setMessage(
                                    LocaleController.getString("WhoCanAddMeInfo", R.string.WhoCanAddMeInfo));
                        } else {
                            builder.setMessage(LocaleController.getString("CustomHelp", R.string.CustomHelp));
                        }
                        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                                new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialogInterface, int i) {
                                        applyCurrentPrivacySettings();
                                        preferences.edit().putBoolean("privacyAlertShowed", true).commit();
                                    }
                                });
                        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                        showDialog(builder.create());
                        return;
                    }
                }
                applyCurrentPrivacySettings();
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
    doneButton.setVisibility(View.GONE);

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

    ListView listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDrawSelectorOnTop(true);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP;
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
            if (i == nobodyRow || i == everybodyRow || i == myContactsRow) {
                int newType = currentType;
                if (i == nobodyRow) {
                    newType = 1;
                } else if (i == everybodyRow) {
                    newType = 0;
                } else if (i == myContactsRow) {
                    newType = 2;
                }
                if (newType == currentType) {
                    return;
                }
                enableAnimation = true;
                doneButton.setVisibility(View.VISIBLE);
                lastCheckedType = currentType;
                currentType = newType;
                updateRows();
            } else if (i == neverShareRow || i == alwaysShareRow) {
                ArrayList<Integer> createFromArray;
                if (i == neverShareRow) {
                    createFromArray = currentMinus;
                } else {
                    createFromArray = currentPlus;
                }
                if (createFromArray.isEmpty()) {
                    Bundle args = new Bundle();
                    args.putBoolean(i == neverShareRow ? "isNeverShare" : "isAlwaysShare", true);
                    args.putBoolean("isGroup", isGroup);
                    GroupCreateActivity fragment = new GroupCreateActivity(args);
                    fragment.setDelegate(new GroupCreateActivity.GroupCreateActivityDelegate() {
                        @Override
                        public void didSelectUsers(ArrayList<Integer> ids) {
                            if (i == neverShareRow) {
                                currentMinus = ids;
                                for (int a = 0; a < currentMinus.size(); a++) {
                                    currentPlus.remove(currentMinus.get(a));
                                }
                            } else {
                                currentPlus = ids;
                                for (int a = 0; a < currentPlus.size(); a++) {
                                    currentMinus.remove(currentPlus.get(a));
                                }
                            }
                            doneButton.setVisibility(View.VISIBLE);
                            lastCheckedType = -1;
                            listAdapter.notifyDataSetChanged();
                        }
                    });
                    presentFragment(fragment);
                } else {
                    PrivacyUsersActivity fragment = new PrivacyUsersActivity(createFromArray, isGroup,
                            i == alwaysShareRow);
                    fragment.setDelegate(new PrivacyUsersActivity.PrivacyActivityDelegate() {
                        @Override
                        public void didUpdatedUserList(ArrayList<Integer> ids, boolean added) {
                            if (i == neverShareRow) {
                                currentMinus = ids;
                                if (added) {
                                    for (int a = 0; a < currentMinus.size(); a++) {
                                        currentPlus.remove(currentMinus.get(a));
                                    }
                                }
                            } else {
                                currentPlus = ids;
                                if (added) {
                                    for (int a = 0; a < currentPlus.size(); a++) {
                                        currentMinus.remove(currentPlus.get(a));
                                    }
                                }
                            }
                            doneButton.setVisibility(View.VISIBLE);
                            listAdapter.notifyDataSetChanged();
                        }
                    });
                    presentFragment(fragment);
                }
            }
        }
    });

    return fragmentView;
}

From source file:com.juick.android.MessagesFragment.java

public static void installDividerColor(ListView listView) {
    ColorsTheme.ColorTheme colorTheme = JuickMessagesAdapter.getColorTheme(listView.getContext());
    ColorDrawable divider = new ColorDrawable(colorTheme.getColor(ColorsTheme.ColorKey.DIVIDER, 0xFF808080));
    listView.setDivider(divider);//from w w w . j a  va2s.  c o  m
    listView.setDividerHeight(1);
}

From source file:com.conferenceengineer.android.iosched.ui.AnnouncementsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ListView listView = getListView();
    if (!UIUtils.isTablet(getActivity())) {
        view.setBackgroundColor(getResources().getColor(R.color.stream_spacer_color));
    }/*from  w ww  .  j a va2 s  .  c  o  m*/

    if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {
        int verticalMargin = getResources().getDimensionPixelSize(R.dimen.social_stream_padding_vertical);
        if (verticalMargin > 0) {
            listView.setClipToPadding(false);
            listView.setPadding(0, verticalMargin, 0, verticalMargin);
        }
    }

    listView.setOnScrollListener(this);
    listView.setDrawSelectorOnTop(true);
    listView.setDivider(getResources().getDrawable(android.R.color.transparent));
    listView.setDividerHeight(getResources().getDimensionPixelSize(R.dimen.page_margin_width));

    TypedValue v = new TypedValue();
    getActivity().getTheme().resolveAttribute(R.attr.activatableItemBackground, v, true);
    listView.setSelector(v.resourceId);

    setListAdapter(mStreamAdapter);
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.AnnouncementsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ListView listView = getListView();
    if (!UIUtils.isTablet(getActivity())) {
        view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color));
    }//  w  w  w.  j a va 2 s  . com

    if (getArguments() != null && getArguments().getBoolean(EXTRA_ADD_VERTICAL_MARGINS, false)) {
        int verticalMargin = getResources().getDimensionPixelSize(R.dimen.plus_stream_padding_vertical);
        if (verticalMargin > 0) {
            listView.setClipToPadding(false);
            listView.setPadding(0, verticalMargin, 0, verticalMargin);
        }
    }

    listView.setOnScrollListener(this);
    listView.setDrawSelectorOnTop(true);
    listView.setDivider(getResources().getDrawable(android.R.color.transparent));
    listView.setDividerHeight(getResources().getDimensionPixelSize(R.dimen.page_margin_width));

    TypedValue v = new TypedValue();
    getActivity().getTheme().resolveAttribute(R.attr.activatableItemBackground, v, true);
    listView.setSelector(v.resourceId);

    setListAdapter(mStreamAdapter);
}

From source file:com.sft.blackcatapp.EnrollSchoolActivity.java

private void showOpenCityPopupWindow(View parent) {
    if (openCityPopupWindow == null) {
        LinearLayout popWindowLayout = (LinearLayout) View.inflate(mContext, R.layout.pop_window, null);
        popWindowLayout.removeAllViews();
        // LinearLayout popWindowLayout = new LinearLayout(mContext);
        popWindowLayout.setOrientation(LinearLayout.VERTICAL);
        ListView OpenCityListView = new ListView(mContext);
        OpenCityListView.setDividerHeight(0);
        OpenCityListView.setCacheColorHint(android.R.color.transparent);
        OpenCityListView.setOnItemClickListener(new OnItemClickListener() {

            @Override//from  w w w  .j av  a  2 s  . c  o  m
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                OpenCityVO selectCity = openCityList.get(position);
                System.out.println(selectCity.getName());
                cityname = selectCity.getName();
                licensetype = "";
                schoolname = "";
                ordertype = "";
                index = 1;
                obtainNearBySchool();
                openCityPopupWindow.dismiss();
                openCityPopupWindow = null;
            }
        });
        LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        popWindowLayout.addView(OpenCityListView, param);
        OpenCityAdapter openCityAdapter = new OpenCityAdapter(mContext, openCityList);
        OpenCityListView.setAdapter(openCityAdapter);

        openCityPopupWindow = new PopupWindow(popWindowLayout, 130, LayoutParams.WRAP_CONTENT);
    }
    openCityPopupWindow.setFocusable(true);
    openCityPopupWindow.setOutsideTouchable(true);
    // Back???
    openCityPopupWindow.setBackgroundDrawable(new BitmapDrawable());

    openCityPopupWindow.showAsDropDown(parent);
}

From source file:org.telegram.ui.CacheControlActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("CacheSettings", R.string.CacheSettings));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//from  ww w .ja  v  a  2 s .  c o  m
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

    ListView listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDrawSelectorOnTop(true);
    frameLayout.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> adapterView, View view, final int i, long l) {
            if (getParentActivity() == null) {
                return;
            }
            if (i == keepMediaRow) {
                BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity());
                builder.setItems(
                        new CharSequence[] { LocaleController.formatPluralString("Weeks", 1),
                                LocaleController.formatPluralString("Months", 1),
                                LocaleController.getString("KeepMediaForever", R.string.KeepMediaForever) },
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, final int which) {
                                SharedPreferences.Editor editor = ApplicationLoader.applicationContext
                                        .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit();
                                editor.putInt("keep_media", which).commit();
                                if (listAdapter != null) {
                                    listAdapter.notifyDataSetChanged();
                                }
                                PendingIntent pintent = PendingIntent.getService(
                                        ApplicationLoader.applicationContext, 0,
                                        new Intent(ApplicationLoader.applicationContext,
                                                ClearCacheService.class),
                                        0);
                                AlarmManager alarmManager = (AlarmManager) ApplicationLoader.applicationContext
                                        .getSystemService(Context.ALARM_SERVICE);
                                if (which == 2) {
                                    alarmManager.cancel(pintent);
                                } else {
                                    alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                                            AlarmManager.INTERVAL_DAY, AlarmManager.INTERVAL_DAY, pintent);
                                }
                            }
                        });
                showDialog(builder.create());
            } else if (i == databaseRow) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                builder.setMessage(
                        LocaleController.getString("LocalDatabaseClear", R.string.LocalDatabaseClear));
                builder.setPositiveButton(LocaleController.getString("CacheClear", R.string.CacheClear),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
                                progressDialog
                                        .setMessage(LocaleController.getString("Loading", R.string.Loading));
                                progressDialog.setCanceledOnTouchOutside(false);
                                progressDialog.setCancelable(false);
                                progressDialog.show();
                                MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
                                    @Override
                                    public void run() {
                                        try {
                                            SQLiteDatabase database = MessagesStorage.getInstance()
                                                    .getDatabase();
                                            ArrayList<Long> dialogsToCleanup = new ArrayList<>();
                                            SQLiteCursor cursor = database
                                                    .queryFinalized("SELECT did FROM dialogs WHERE 1");
                                            StringBuilder ids = new StringBuilder();
                                            while (cursor.next()) {
                                                long did = cursor.longValue(0);
                                                int lower_id = (int) did;
                                                int high_id = (int) (did >> 32);
                                                if (lower_id != 0 && high_id != 1) {
                                                    dialogsToCleanup.add(did);
                                                }
                                            }
                                            cursor.dispose();

                                            SQLitePreparedStatement state5 = database
                                                    .executeFast("REPLACE INTO messages_holes VALUES(?, ?, ?)");
                                            SQLitePreparedStatement state6 = database.executeFast(
                                                    "REPLACE INTO media_holes_v2 VALUES(?, ?, ?, ?)");

                                            database.beginTransaction();
                                            for (int a = 0; a < dialogsToCleanup.size(); a++) {
                                                Long did = dialogsToCleanup.get(a);
                                                int messagesCount = 0;
                                                cursor = database.queryFinalized(
                                                        "SELECT COUNT(mid) FROM messages WHERE uid = " + did);
                                                if (cursor.next()) {
                                                    messagesCount = cursor.intValue(0);
                                                }
                                                cursor.dispose();
                                                if (messagesCount <= 2) {
                                                    continue;
                                                }

                                                cursor = database.queryFinalized(
                                                        "SELECT last_mid_i, last_mid FROM dialogs WHERE did = "
                                                                + did);
                                                int messageId = -1;
                                                if (cursor.next()) {
                                                    long last_mid_i = cursor.longValue(0);
                                                    long last_mid = cursor.longValue(1);
                                                    SQLiteCursor cursor2 = database.queryFinalized(
                                                            "SELECT data FROM messages WHERE uid = " + did
                                                                    + " AND mid IN (" + last_mid_i + ","
                                                                    + last_mid + ")");
                                                    try {
                                                        while (cursor2.next()) {
                                                            NativeByteBuffer data = cursor2.byteBufferValue(0);
                                                            if (data != null) {
                                                                TLRPC.Message message = TLRPC.Message
                                                                        .TLdeserialize(data,
                                                                                data.readInt32(false), false);
                                                                data.reuse();
                                                                if (message != null) {
                                                                    messageId = message.id;
                                                                }
                                                            }
                                                        }
                                                    } catch (Exception e) {
                                                        FileLog.e("tmessages", e);
                                                    }
                                                    cursor2.dispose();

                                                    database.executeFast("DELETE FROM messages WHERE uid = "
                                                            + did + " AND mid != " + last_mid_i + " AND mid != "
                                                            + last_mid).stepThis().dispose();
                                                    database.executeFast(
                                                            "DELETE FROM messages_holes WHERE uid = " + did)
                                                            .stepThis().dispose();
                                                    database.executeFast(
                                                            "DELETE FROM bot_keyboard WHERE uid = " + did)
                                                            .stepThis().dispose();
                                                    database.executeFast(
                                                            "DELETE FROM media_counts_v2 WHERE uid = " + did)
                                                            .stepThis().dispose();
                                                    database.executeFast(
                                                            "DELETE FROM media_v2 WHERE uid = " + did)
                                                            .stepThis().dispose();
                                                    database.executeFast(
                                                            "DELETE FROM media_holes_v2 WHERE uid = " + did)
                                                            .stepThis().dispose();
                                                    BotQuery.clearBotKeyboard(did, null);
                                                    if (messageId != -1) {
                                                        MessagesStorage.createFirstHoles(did, state5, state6,
                                                                messageId);
                                                    }
                                                }
                                                cursor.dispose();
                                            }
                                            state5.dispose();
                                            state6.dispose();
                                            database.commitTransaction();
                                            database.executeFast("VACUUM").stepThis().dispose();
                                        } catch (Exception e) {
                                            FileLog.e("tmessages", e);
                                        } finally {
                                            AndroidUtilities.runOnUIThread(new Runnable() {
                                                @Override
                                                public void run() {
                                                    try {
                                                        progressDialog.dismiss();
                                                    } catch (Exception e) {
                                                        FileLog.e("tmessages", e);
                                                    }
                                                    if (listAdapter != null) {
                                                        File file = new File(
                                                                ApplicationLoader.getFilesDirFixed(),
                                                                "cache4.db");
                                                        databaseSize = file.length();
                                                        listAdapter.notifyDataSetChanged();
                                                    }
                                                }
                                            });
                                        }
                                    }
                                });
                            }
                        });
                showDialog(builder.create());
            } else if (i == cacheRow) {
                if (totalSize <= 0 || getParentActivity() == null) {
                    return;
                }
                BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity());
                builder.setApplyTopPadding(false);
                builder.setApplyBottomPadding(false);
                LinearLayout linearLayout = new LinearLayout(getParentActivity());
                linearLayout.setOrientation(LinearLayout.VERTICAL);
                for (int a = 0; a < 6; a++) {
                    long size = 0;
                    String name = null;
                    if (a == 0) {
                        size = photoSize;
                        name = LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache);
                    } else if (a == 1) {
                        size = videoSize;
                        name = LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache);
                    } else if (a == 2) {
                        size = documentsSize;
                        name = LocaleController.getString("LocalDocumentCache", R.string.LocalDocumentCache);
                    } else if (a == 3) {
                        size = musicSize;
                        name = LocaleController.getString("LocalMusicCache", R.string.LocalMusicCache);
                    } else if (a == 4) {
                        size = audioSize;
                        name = LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache);
                    } else if (a == 5) {
                        size = cacheSize;
                        name = LocaleController.getString("LocalCache", R.string.LocalCache);
                    }
                    if (size > 0) {
                        clear[a] = true;
                        CheckBoxCell checkBoxCell = new CheckBoxCell(getParentActivity());
                        checkBoxCell.setTag(a);
                        checkBoxCell.setBackgroundResource(R.drawable.list_selector);
                        linearLayout.addView(checkBoxCell,
                                LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
                        checkBoxCell.setText(name, AndroidUtilities.formatFileSize(size), true, true);
                        checkBoxCell.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                CheckBoxCell cell = (CheckBoxCell) v;
                                int num = (Integer) cell.getTag();
                                clear[num] = !clear[num];
                                cell.setChecked(clear[num], true);
                            }
                        });
                    } else {
                        clear[a] = false;
                    }
                }
                BottomSheet.BottomSheetCell cell = new BottomSheet.BottomSheetCell(getParentActivity(), 1);
                cell.setBackgroundResource(R.drawable.list_selector);
                cell.setTextAndIcon(
                        LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache).toUpperCase(),
                        0);
                cell.setTextColor(Theme.STICKERS_SHEET_REMOVE_TEXT_COLOR);
                cell.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        try {
                            if (visibleDialog != null) {
                                visibleDialog.dismiss();
                            }
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        cleanupFolders();
                    }
                });
                linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
                builder.setCustomView(linearLayout);
                showDialog(builder.create());
            }
        }
    });

    return fragmentView;
}