android:scrollingCache=”false” を設定
ImageView imageView = (ImageView)findViewBy ( R.id.image1 ) ;
Bitmap bmp = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
String[] words = {"cat", "dog", "man"};
List<String> wordList = Arrays.asList(words);
final ArrayList<String> rows = new ArrayList<String>(Arrays.asList(getResources().getStringArray(R.array.safe_search_list)));
resource 定義
<string-array name="safe_search_list">
<item>active</item>
<item>moderate</item>
<item>off</item>
</string-array>
6月 142013
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/black" />
てな感じ
5月 022013
Locale locale = Locale.getDefault();
if( locale.getLanguage().equals( Locale.JAPAN.getLanguage() )) {
// 日本語
} else {
// 日本語以外
}
なんか直接はできないみたい。
なので、使用前に saveSetting, 使用後に loadSetting で取り合えず使える。
※ ディフォルトのファイル名は、”パッケージ名+_preferences.xml”
void public saveSetting( Context c, String exterernalPath) {
String to = c.getFilesDir().getParentFile().getAbsoluteFile() + "/shared_prefs/my_setting.xml";
// 外部SD->内部SD
copyFile( exterernalPath, to ) ;
}
void public loadSetting( Context c, String exterernalPath) {
String to = c.getFilesDir().getParentFile().getAbsoluteFile() + "/shared_prefs/my_setting.xml";
// 内部SD->外部SD
copyFile( to, exterernalPath ) ;
}
public static void copyFile(String srcFilePath, String dstFilePath) {
File srcFile = new File(srcFilePath);
File dstFile = new File(dstFilePath);
// ディレクトリを作る.
File dstPath = new File(dstFile.getParent());
dstPath.mkdirs();
try {
// ファイルコピーのフェーズ
InputStream input = null;
OutputStream output = null;
input = new FileInputStream(srcFile);
output = new FileOutputStream(dstFile);
int DEFAULT_BUFFER_SIZE = 1024 * 4;
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
}
input.close();
output.close();
} catch (Exception e) {
e.printStackTrace();
}
4月 192013
内部SDにDBを保存するとツール等使って直接参照できません。
てっ事で、外部SDに保存する方法が以下です。
あっ、OSのバージョンよっては出来ないのもあるのかな?
4.X 系はOK
public class DatabaseHelper extends SQLiteOpenHelper {
private final static int DB_VERSION = 1;
public final static String DB_NAME = "mydb.db";
public DatabaseHelper(Context context) {
super(context,
Environment.getExternalStorageDirectory().getAbsolutePath() + "/hogehoge/" + DB_NAME,
null,
DB_VERSION);
}
}
POSTでパラメータを配列で渡すことになりました。
(@_@)
連想配列ならピンとくるんですが、ただの配列ってなあに?
調べた結果
GETイメージだと
http:/localhost/request.php?hoge[]=a&hoge[]=b&hoge[]=c
てな感じです。
でっ Android で指定するには?
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> para = new ArrayList<NameValuePair>() ;
for( String hoge : list ) {
para.add( new BasicNameValuePair("hoge[]", hoge));
}
httpPost.setEntity(new UrlEncodedFormEntity( para, "UTF-8"));
HttpResponse response = httpclient.execute(httpPost);
以下設定
android-15 以上ならSDKにソースが付属されています。
eclipse
設定->Javaのビルドパス->ライブラリー->Android 4.0.3->android.jar->ソース添付
編集ボタン->外部フォルダー
ex.C:/android-sdk_r20.0.3-windows/android-sdk-windows/sources/android-15
[/text:
上記でソースデバック出来ます。
3月 282013
当たり前と言えば、当たり前
でも気付かないと嵌るって事でメモ
Intent intent = new Intent( "myaction.name"); // toString を忘れると CharSequence となるので getExtraString では受け取れない! EditText x = (EditText)findViewById(R.id.editText_x); intent.putExtra( "X", x.getText().toString());