Skip to content

Instantly share code, notes, and snippets.

View androidcodehunter's full-sized avatar

Sharifur Rahaman androidcodehunter

View GitHub Profile
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/**
* Share quote and wait for response. If response -1, the post has been published otherwise not published.
* */
private void shareQuote() {
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = mQuote.getQuote();
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mQuote.getQuotedBy());
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivityForResult(Intent.createChooser(sharingIntent, "Share via...."), SHARE_REQUEST_CODE);
@androidcodehunter
androidcodehunter / .txt
Last active September 17, 2016 16:17
Android Utility Methods
প্রতিদিন আমরা ডেভেলপমেন্ট করার সময় বিভিন্ন মেথদস ব্যবহার করি যা সবসময় প্রয়োজন হয়। এখানে আমি যখন যেটা পাই সেটা সেইভ করে রাখব যাতে পরবর্তিতে সহজে ব্যবহার করেতে পারি।
@androidcodehunter
androidcodehunter / toolbarcolor
Created October 8, 2016 04:48
How to change toolbar back arrow color and title color?
From theme
<style name="SearchToolbar" parent="Theme.AppCompat.Light.NoActionBar">
//toolbar back arrow color
<item name="android:textColorSecondary">@android:color/white</item>
//toolbar title color
<item name="android:textColorPrimary">@android:color/white</item>
</style>
Also we can do it from java code:
@androidcodehunter
androidcodehunter / Remove Highlighted ClickSpan
Created October 13, 2016 05:31
Removing highlighted color from ClickableSpan in Android
I’ve been struggling for some hours with TextView and Spannable.. ClickableSpan to be precise. It seems that when you tap the clickable text it gets an ugly orange stroke (might differ on devices) around the text and if you so happen to have this in a custom view as an item in e.g Gallery it really stands out by highlighting it everytime you scroll away from that view. Annoying, yes?
The solution is extremely simple and was provided by a thread over at Stackoverflow.com.
To edit or remove the higlight color you can simply set the TextViews highlight color itself to any color you want or Color.TRANSPARENT if you don’t want any color.
android:textColorHighlight="@color/something"
or in code
textView.setHighlightColor(Color.TRANSPARENT);
@androidcodehunter
androidcodehunter / siftkeyboard
Created October 17, 2016 11:20
Hide Softkeyboard outside clicking of Edittext.
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
View v = getCurrentFocus();
boolean result = super.dispatchTouchEvent(event);
if (v instanceof EditText) {
View w = getCurrentFocus();
int coords[] = new int[2];
w.getLocationOnScreen(coords);
float x = event.getRawX() + w.getLeft() - coords[0];
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.new_group));
final FrameLayout input = (FrameLayout) View.inflate(this, R.layout.dialog_profile_name_update, null);
final EditText editText = (EditText) input.findViewById(R.id.et_rename_profile_name);
editText.setHint(getString(R.string.hint_name_this_group_chat));
editText.setText(getString(R.string.label_group));
editText.setSelection(getString(R.string.label_group).length());
builder.setView(input);
builder.setPositiveButton(getString(R.string.dialog_positive_btn_ok), new DialogInterface.OnClickListener() {
<!--
android:colorAccent will affect your text colors of negative or positive buttons.
android:textColor will affect your title text color of dialog.
android:textColorPrimary will affect your message color of dialog.-->
<style name="GGDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColor">@color/theme_blue</item>
<item name="android:background">@color/white</item>
<item name="android:textColorPrimary">@color/theme_red</item>
<item name="colorAccent">@color/theme_red</item>
</style>
package com.assignment;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Student {
private int id;
private String name, gender;
private Date dateOfBirth;