ldpi,mdpi,hdpi,xhdpi,xxhdpi,xxxhdpi
float xdpi = getResources().getDisplayMetrics().xdpi;
float ydpi = getResources().getDisplayMetrics().ydpi;
https://blog.csdn.net/guolin_blog/article/details/50727753
https://developer.android.com/reference/android/util/DisplayMetrics.html
2019年3月21日木曜日
2018年11月12日月曜日
AboutDialog の追加
AboutDialog の追加
public class AboutDialog extends AlertDialog {
private Context context;
public AboutDialog(Context context) {
super(context);
this.context = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout li = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.about_layout, null);
TextView textView = li.findViewById(R.id.textView3);
textView.setText(Html.fromHtml("<u>" + getString(R.string.GooglePlayStore) + "<u>"));
Pattern pattern = Pattern.compile("");
String url = getString(R.string.PlayURL);
Linkify.addLinks(textView, pattern, url, null, null);
setContentView(li);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="30dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
app:srcCompat="@mipmap/ic_launcher_foreground" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/app_name"
android:textSize="30dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/kankanla"
android:textSize="20dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/GooglePlayStore"
android:textSize="20dp" />
</LinearLayout>
public class AboutDialog extends AlertDialog {
private Context context;
public AboutDialog(Context context) {
super(context);
this.context = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout li = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.about_layout, null);
TextView textView = li.findViewById(R.id.textView3);
textView.setText(Html.fromHtml("<u>" + getString(R.string.GooglePlayStore) + "<u>"));
Pattern pattern = Pattern.compile("");
String url = getString(R.string.PlayURL);
Linkify.addLinks(textView, pattern, url, null, null);
setContentView(li);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="30dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
app:srcCompat="@mipmap/ic_launcher_foreground" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/app_name"
android:textSize="30dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/kankanla"
android:textSize="20dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:text="@string/GooglePlayStore"
android:textSize="20dp" />
</LinearLayout>
ラベル:
Android_Layout
2018年11月10日土曜日
Ads SDK
******************************************************************************
* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers *
* should follow the instructions here: https://goo.gl/fQ2neu to add a valid *
* App ID inside the AndroidManifest. Google Ad Manager publishers should *
* follow instructions here: https://goo.gl/h17b6x. *
******************************************************************************
* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers *
* should follow the instructions here: https://goo.gl/fQ2neu to add a valid *
* App ID inside the AndroidManifest. Google Ad Manager publishers should *
* follow instructions here: https://goo.gl/h17b6x. *
******************************************************************************
2018年10月28日日曜日
3.5 毫米耳机:配件规范
3.5 毫米耳机:配件规范
https://source.android.com/devices/accessories/headset/plug-headset-spec
https://source.android.com/devices/accessories/headset/plug-headset-spec
直接启动
直接启动
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
https://developer.android.com/training/articles/direct-boot?hl=zh-cn
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
https://developer.android.com/training/articles/direct-boot?hl=zh-cn
2018年10月23日火曜日
アルファベットArrayList作成
import java.util.*;
class chart {
public static void main(String[] args) {
ArrayList<String> keyList = new ArrayList<>();
for (int i = 0x41; i < 0x5B; i++) {
keyList.add(String.valueOf((char)i));
}
for (int i = 0x30; i < 0x3A; i++) {
keyList.add(String.valueOf((char)i));
}
System.out.println(keyList);
String x = keyList.toString();
char[] temp = x.toCharArray();
temp = x.toCharArray();
for (char cc : temp) {
System.out.println(cc);
}
StringBuffer temp2 = new StringBuffer();
for(String xx :keyList){
temp2.append(xx);
}
System.out.println(temp2);
}
}
class chart {
public static void main(String[] args) {
ArrayList<String> keyList = new ArrayList<>();
for (int i = 0x41; i < 0x5B; i++) {
keyList.add(String.valueOf((char)i));
}
for (int i = 0x30; i < 0x3A; i++) {
keyList.add(String.valueOf((char)i));
}
System.out.println(keyList);
String x = keyList.toString();
char[] temp = x.toCharArray();
temp = x.toCharArray();
for (char cc : temp) {
System.out.println(cc);
}
StringBuffer temp2 = new StringBuffer();
for(String xx :keyList){
temp2.append(xx);
}
System.out.println(temp2);
}
}
2018年9月12日水曜日
【Android】快速切换到主线程更新UI的几种方法
【Android】快速切换到主线程更新UI的几种方法
方法一: view.post(Runnable action)
textView.post(new Runnable() {
@Override
public void run() {
textView.setText("更新textView");
//还可以更新其他的控件
imageView.setBackgroundResource(R.drawable.update);
}
});
方法二: activity.runOnUiThread(Runnable action)
public void updateUI(final Context context) {
((MainActivity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
//此时已在主线程中,可以更新UI了
}
});
}
方法三: Handler机制
...
方法一: view.post(Runnable action)
textView.post(new Runnable() {
@Override
public void run() {
textView.setText("更新textView");
//还可以更新其他的控件
imageView.setBackgroundResource(R.drawable.update);
}
});
方法二: activity.runOnUiThread(Runnable action)
public void updateUI(final Context context) {
((MainActivity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
//此时已在主线程中,可以更新UI了
}
});
}
方法三: Handler机制
...
登録:
投稿 (Atom)