View SomeFragment.java
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);
View HideKeyboard.java
public void hideSoftInputKeyBoard(View view) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null && view != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
View TextViewClickableUnderlineColorChange.java
//Terms of Service
String tobeClickable = getString(R.string.tos);
int index = getString(R.string.terms_of_service).indexOf(tobeClickable);
int length = index + tobeClickable.length();
//I agree to FireSonar's Terms of Service
Spannable spannableString = new SpannableString(
getString(R.string.terms_of_service));
ClickableSpan clickableSpan = new ClickableSpan() {
View test.json
{
"following": [
{
"name" : "john doe",
"following" : true,
"created_at" : "1 hour ago",
"picture" : "http://i.imgur.com/DA8VXak.jpg"
},
{
"name" : "john doe",
View BaseEditText.java
public class BaseEditText extends EditText {
public BaseEditText(Context context) {
this(context, null);
}
public BaseEditText(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public BaseEditText(Context context, AttributeSet attrs, int defStyle) {
View BitmapToInputStream.java
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 0 /*ignored for PNG*/, bos);
byte[] bitmapdata = bos.toByteArray();
ByteArrayInputStream bs = new ByteArrayInputStream(bitmapdata);
View GetImagePathFromCamera
Cursor cursor = getContentResolver().query(Media.EXTERNAL_CONTENT_URI, new String[]{Media.DATA, Media.DATE_ADDED, MediaStore.Images.ImageColumns.ORIENTATION}, Media.DATE_ADDED, null, "date_added ASC");
if(cursor != null && cursor.moveToFirst())
{
do {
uri = Uri.parse(cursor.getString(cursor.getColumnIndex(Media.DATA)));
photoPath = uri.toString();
}while(cursor.moveToNext());
cursor.close();
}
View DialogFragment.java
DialogFragment dg = new DialogFragment() {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setMessage(R.string.submit_confirm_message)
.setPositiveButton(R.string.submit_confirm_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
/*---THIS IS ADDED EXTRA--------*/
postInfoToServer();
View DialogWithLinkText.java
final TextView tv = new TextView(this);
final SpannableString s = new SpannableString(result);
Linkify.addLinks(s, Linkify.WEB_URLS);
tv.setText(s);
tv.setMovementMethod(LinkMovementMethod.getInstance());
DialogFragment dg = new DialogFragment() {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
View ViewPagerCurrentFragment.java
Fragment fragment = (Fragment) mPagerAdapter.instantiateItem(mPager, mPager.getCurrentItem());