タイトル | : Android 文字入力数字の背景が黒くなった |
投稿日 | : 2022/02/11(Fri) 11:11 |
投稿者 | : kasai |
Android 200 :電話番号入力の数字の背景が黒くなりました。
alt+enterはやったつもりです。
画面wをメールで送付しますので、よろしくお願いいたします。
MainActivity.java[
package com.example.maptel;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
//地図連携メソッド
public void map(View view){
//文字列取得
Resources res = getResources();
String address = res.getString(R.string.map_address);
//地図インテント
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("geo:0,0?q="+address));
startActivity(intent);
}
//電話連携のメソッド
public void call(View view){
//文字列取得
Resources res = getResources();
String msg = res.getString(R.string.call_msg);
//電話番号取得
EditText textInput = (EditText)findViewById(R.id.editText1);
String call= textInput.getText().toString();
//先頭が0か判断
if (call.substring(0,1).equals("0")){
//電話インテント
Intent intent = new Intent();
intent.setAction(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:"+call));
startActivity(intent);
}else{
//TextViewの作成
TextView textView = new TextView(getApplicationContext());
textView.setText(msg); //メッセージ
textView.setTextSize(25); //フォント
textView.setTextColor(Color.RED); //文字色
textView.setBackgroundColor(Color.BLACK); //背景色
//ToastにTextViewをセットして表示する
Toast toast = new Toast(getApplicationContext());
toast.setView(textView);
toast.setDuration(Toast.LENGTH_LONG);
toast.show();
}
}
}
]