Monday, March 30, 2015

How to write style to error text of EditText in android?


int ecolor = R.color.black; String estring = "Please enter a valid email address";

ForegroundColorSpan fgcspan = new ForegroundColorSpan(ecolor);
SpannableStringBuilder ssbuilder = new SpannableStringBuilder(estring);
ssbuilder.setSpan(fgcspan, 0, estring.length(), 0);
edtEmail.requestFocus();
edtEmail.setError(ssbuilder); 

Friday, February 13, 2015

Current local time in UTC

   
        try {
            Calendar calendar = Calendar.getInstance();
            int month = calendar.getTime().getMonth() + 1;
            String timeStampToMatch = calendar.getTime().getDate() + "-"
                    + month + "-" + calendar.get(Calendar.YEAR) + " "
                    + "01:01 pm";

            Log.i("======>", timeStampToMatch);

            DateFormat dateFormat = new SimpleDateFormat("d-M-yyyy H:m");

            Date date = dateFormat.parse(timeStampToMatch);
            dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
            Log.i("======>", dateFormat.format(date));

        } catch (ParseException e) {
            e.printStackTrace();
        }


Using common Layout and its event in all activities

ViewGroup vg = (ViewGroup) findViewById(R.id.lldata);
ViewGroup.inflate(getApplicationContext(), R.layout.listwitter, vg);