Skip to content

Instantly share code, notes, and snippets.

View sakurabird's full-sized avatar
💭
I may be slow to respond.

Yukari Sakurai sakurabird

💭
I may be slow to respond.
View GitHub Profile
@sakurabird
sakurabird / ExpandableHeightGridView.java
Last active April 6, 2023 17:20
AndroidのScrollViewの中のGridViewのlayout_heightが伸び縮みしないのを独自Viewで克服
package xx.xxx.xx.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.GridView;
/**
* ScrollViewの中のGridViewでも高さを可変にする<br>
* http://stackoverflow.com/questions/8481844/gridview-height-gets-cut
@sakurabird
sakurabird / gist:6923317
Created October 10, 2013 18:40
(Android)Intentでメールアプリを呼び出す。セキュリティ上好ましい方法
public void onClick1(View view) {
// logcatにメールアドレスが表示される呼び出し方。セキュリティ上好ましくない
Uri uri = Uri.parse("mailto:" + mail);
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(intent);
}
public void onClick2(View view) {
// logcatにメールアドレスが表示されない呼び出し方。セキュリティ上好ましい
Uri uri = Uri.parse("mailto:");
@sakurabird
sakurabird / AnimationTest1.java
Last active May 18, 2021 03:00
(android)TextViewの文字をスクロールする。xmlでアニメーションを定義する。 右から文字が流れてきて一番左までマーキーしたら止まる。
package com.example.AnimationTest1;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
public class AnimationTest1 extends Activity
{
@Override
@sakurabird
sakurabird / gist:6868909
Last active January 13, 2021 23:17
AndroidのScrollViewの中でもうまくGridViewのScrollを効かす
mGridView = (GridView) getView().findViewById(R.id.spotsView);
mGridView.setOnTouchListener(new GridView.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// ScrollViewの中でもうまくGridViewのScrollを効かす
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
@sakurabird
sakurabird / AndroidManifest.xml
Created July 10, 2012 14:04
イメージを選択する。Intent.ACTION_PICKとIntent.ACTION_GET_CONTENTの違いを比較する
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sakurafish.android.example.myexamplechooseimage"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
@sakurabird
sakurabird / CircleImageView.java
Created July 9, 2015 13:51
CircleImageView for Material Design.
/**
* Copyright 2015-present Yukari Sakurai
* <p/>
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
@sakurabird
sakurabird / Kind.swift
Last active August 22, 2018 03:44
Swift4.0 Codable + Realm (CodableでJsonをパース→RealmでDBに投入)
//
// Kind.swift
// ExamRealm1
//
// Created by Sakura on 2018/01/22.
// Copyright © 2018年 Sakura. All rights reserved.
//
import Foundation
import RealmSwift
@sakurabird
sakurabird / newline2.rb
Last active August 29, 2017 15:36
入力ファイルから出力ファイルに書き出すRubyのプログラム。n文字毎に改行コードも挿入する。
##################################################
# 入力ファイルから出力ファイルに書き出すRubyのプログラム
# 入力ファイルはテキストファイルである
# テキストはランダムに改行されている
# 文字がn文字を超えていたらn文字で改行する
# 実行方法はコマンドラインから次のように打ち込む。Ruby必須
# $ ruby newline2.rb
##################################################
@sakurabird
sakurabird / newline.rb
Last active August 26, 2017 04:50
入力ファイル(Unix系OS Macも含む)から出力ファイル(Windows)に書き出すRubyのプログラム。n文字毎に改行コードも挿入する。
##################################################
# 入力ファイル(Unix系OS Macも含む)から出力ファイル(Windows)に書き出すRubyのプログラム
# 入力ファイルはテキストファイルである
# テキストはランダムに改行されている
# 文字がn文字を超えていたらn文字で改行する
# 実行方法はコマンドラインから次のように打ち込む。Ruby必須
# $ ruby newline.rb
##################################################
@sakurabird
sakurabird / gist:1309003
Created October 24, 2011 13:16
Untouchable 音声認識
//インスタンス変数の定義
SpeechRecognizer rec;
//onCreate()で変数にリスナーをセットする
// 音声認識
rec = SpeechRecognizer.createSpeechRecognizer( getApplicationContext() );
rec.setRecognitionListener( new speechListenerAdp() );
//音声認識をスタートする
// SpeechRecognizer