AndroidのプログラミングでTextViewやEditTextの文字が表示されない問題

このQ&Aのポイント
  • Android StudioでTextViewやEditTextを作成すると、文字が表示されない問題が発生しています。
  • 今までは新しく作成したTextViewには正常に文字が表示されていたのに、途中から文字が表示されなくなりました。
  • Buttonでは文字が表示されるのに、TextやEditTextでは表示されない問題が発生しています。
回答を見る
  • ベストアンサー

androidのプログラミングについて

現在android studio でプログラミングをしているのですが 今まではTextViewを新しく作ったときはnewtextという文字が表示されたのに なぜかプログラムをつくっている途中新しいTextViewwを作ったら 文字が表示されなくなってしまいましたandroid:text=がないのかと思い xmlのtextのほうを見ましたがちゃんとandroid:text="newtext"がありました 表示する文字をひらがなにしたり数字にしたりしましたがエミュや実機でも 表示されませんでしたただButtonではなぜかandroid:text=を使えば文字が表示されました どうもTextやEditTextらへんが文字が表示されなくなっているようです

質問者が選んだベストアンサー

  • ベストアンサー
  • y_shimizu
  • ベストアンサー率41% (27/65)
回答No.1

背景色と文字色が同じで表示しても見えないとかではないですよね?

abesi3n
質問者

お礼

よく見たら画面全体の色とテキストの色が同じでした ひじょうに助かりました!ありがとうございます!

abesi3n
質問者

補足

回答ありがとうございます! 見てみましたが間違いはありませんでした

関連するQ&A

  • Androidのレイアウトについて

    XMLで作成したTextViewを処理中に色を変えることは出来ないのでしょうか? 下記のようにやれば実装できるのでは?と思ってやってみましたがダメでした、 XMLファイルを使った方法で文字の色を変更する事は可能ですか? hogehoge.xml---------------------------------------------- <TextView android:id="@+id/text" android:textColor="@color/black" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="hogehoge" /> hogehoge.java--------------------------------------------- EditText textView=(EditText)findViewById(R.id.text); textView.setTextColor(Color.RED); ---------------------------------------------------------

  • androidのプログラミングについて

    現在android studioでプログラミングをしているのですが アクションバーを使わないものを作る予定だったので NoActionBarをManifest.xmlに入力しアクションバーを消したのですが 実機やエミュではちゃんと消えているのになぜか xmlのDesignでは消えていないのです どうすればDesignのアクアションバーを消せますか?

  • EclipseでEditTextが表示されない!

    はじめまして、よろしくお願いいたします。 EclipseでのAndroidアプリの勉強を始めた者です。 Androidアプリの本に従い、メモ帳アプリを作成中ですが、 EditTextがパレットに表示されません。 ■環境 ・Android 4.0.3 ・Eclipse ■手順 ・main.xmlを開く ・GraphicalLayoutをクリックしパレットを見る。 ・FormWidgetsを見るが、TextViewとかButtonとかはあるものの、EditTextが見当たらない。 ・一応ほかのカテゴリーを見ても同様に見当たらない。 何かEditTextビューを使用するために必要な作業があるのでしょうか? こんな質問で申し訳ございませんが、よろしくお願いいたします。

    • ベストアンサー
    • Java
  • androidでアプリを作ろうとしてるのですが

    package com.example.test; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; public class InOutTest extends Activity { /** Called when the activity is first created. */ public TextView txtInfo; public EditText edtText; public Button outputbutton; public TextView txtResult; public TextView txtjudge; public String strInch; public String gettext; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //レイアウト作成 ここから LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); setContentView(layout); //レイアウトを見えるようにする //レイアウト作成 ここまで //GUI部品作成 ここから // ラベル txtInfo = new TextView(this); txtInfo.setText("check"); strInch = ("check"); layout.addView(txtInfo); // エディタ edtText = new EditText(this); layout.addView(edtText); // ボタン txtResult = new Button(this); txtResult.setText("same or difference"); layout.addView(txtResult); // 結果表示用ラベル txtjudge = new TextView(this); txtjudge.setText("check"); layout.addView(txtjudge); //GUI部品作成 ここまで txtResult.setOnClickListener(new OnClickListener(){ public void onClick(View v) { gettext = edtText.toString(); if (strInch==gettext){ txtjudge.setText("ok"); } }; }); }} 上のプログラムで strInchに入ってるデータとgettextで取得した文章を比較して同じなら txtjudgeにOKと引き渡して表示させたいのですがうまく動きません 何方かどうぞよろしくお願い致します

    • ベストアンサー
    • Java
  • android TableLayout使用時で

    いつもお世話になっています。 android TableLayout使用時のことで質問します。 forでTextViewに値を入れていきたいのですが、このときxmlでTextViewをひとつ作っておいてそのTextViewを使いまわすことはできないのでしょうか? したいのが、 for文で、TableRowに値を入れていきたい。 private final int WC = ViewGroup.LayoutParams.WRAP_CONTENT; private final int FP = ViewGroup.LayoutParams.FILL_PARENT; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); TableLayout tableLayout = new TableLayout(this); setContentView(tableLayout); for(int a=0;a<3;a++){ TextView text1 = new TextView(this); text1.setText("user"); TableRow tableRow1 = new TableRow(this); tableRow1.addView(text1); tableLayout.addView(tableRow1, createParam(FP, WC)); } } private TableLayout.LayoutParams createParam(int w, int h){ return new TableLayout.LayoutParams(w, h); } この時表示されたのが、 user user user この方法を、xmlのTextViewを呼ぶ形で実現したいのですが、 xmlでは、 <TableRow> ↓ このTextViewを使いまわしたい。 <TextView android:id="@+id/user" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Test"> </TextView> </TableRow> で、表記しています。 xmlでは、普通に先に記述していないと使えないのでしょうか? つまり、もしTableにTextViewを3つ使いたいなら、TextViewを既に3つ記述していないと使えないものなのでしょうか? よろしくお願いします。

    • ベストアンサー
    • Java
  • androidプログラミングについての質問

    このプログラムについて質問したいのですが public class InOutTest extends Activity { /** Called when the activity is first created. */ public TextView txtInfo; public EditText edtText; public Button outputbutton; public TextView txtResult; public TextView txtjudge; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //レイアウト作成 ここから LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); setContentView(layout); //レイアウトを見えるようにする //レイアウト作成 ここまで //GUI部品作成 ここから // ラベル txtInfo = new TextView(this); txtInfo.setText("check spell same or not:"); layout.addView(txtInfo); // エディタ edtText = new EditText(this); layout.addView(edtText); // ボタン txtResult = new Button(this); txtResult.setText("same or difference"); layout.addView(txtResult); // 結果表示用ラベル txtjudge = new TextView(this); txtjudge.setTextSize(30f); layout.addView(txtjudge); //GUI部品作成 ここまで txtResult.setOnClickListener(new OnClickListener(){ public void onClick(View v) { String strInch = ""; if (edtText==txtInfo) strInch = "typed as same"; txtResult.setText(strInch); } }); } } txtResultに文章を引き渡して表示させたいのですが やり方が分かりません お時間のある方でいいので どなたかよろしければ教えてください

  • 【Android開発】ボタンのテキスト表示

    Android初心者です。現在画面遷移先の画面に配列で設定した質問文、選択肢を表示するアプリを制作しています。質問文はTextView、選択肢は2つのButtonにテキストとして表示する。画面遷移した後にsetQuestion()、setChoiceを呼び出したいんですが実機で試したところ、画面遷移した後に「問題が発生しため、(アプリ名)を終了します」とポップアップが出て、アプリが落ちます。 この2つのメソッドをonCreateに入れるのは間違なのでしょうか?どうすればうまくいきますか?初心者なのでうまく書けてないかも知れません。 よろしくお願いします。 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sub); setChoice(); setQuestion();  } int number = 0; //質問番号 //選択肢 Button button1; Button button2; Button button3; Button button4; //質問文を配列に格納 static String question[] = { "質問文1", "質問文2", }; //選択肢 static String choice[][] = { {"1番", "2番", "3番", "4番"}, {"1番", "2番", "3番", "4番"}, }; //問題の回答 static String answer[] = { "2番", "4番" }; //出力 //質問文を表示 public void setQuestion() { String setQuestion = question[number]; // TextView question = (TextView) findViewById(R.id.Question); question.setText(setQuestion); } //選択肢の表示 public void setChoice() { TextView button1 = (Button) findViewById(R.id.button1); TextView button2 = (Button) findViewById(R.id.button2); button1.setText(choice[number][0]); button2.setText(choice[number][1]); } xml <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Question" android:id="@+id/Question" android:textSize="40dp" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="81dp" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button1" android:textSize="30dp" android:onClick="choiceClick" android:layout_above="@+id/button2" android:layout_centerHorizontal="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button2" android:textSize="30dp" android:onClick="choiceClick" android:layout_alignParentBottom="true" android:layout_alignLeft="@+id/button1" android:layout_alignStart="@+id/button1" />

  • Androidコンパイル時のエラーについて

    Androidの開発中に下記エラーが出ます。 対処の解る方がおりましたらば教えていただけますでしょう 宜しくお願いいたします。 詳細内容及びソース、XML エラー 2011-05-11 16:09:27 - BMICalculator2] res\layout\main.out.xml:0: Originally defined here. [2011-05-11 16:09:27 - BMICalculator2] C:\workspace\BMICalculator2\res\values\strings.out.xml:1: エラー: Error parsing XML: no element found [2011-05-11 16:09:27 - BMICalculator2] C:\workspace\BMICalculator2\res\layout\main.out.xml:1: エラー: Error parsing XML: no element found [2011-05-11 16:09:27 - BMICalculator2] C:\workspace\BMICalculator2\res\layout\main.xml:38: エラー: エラー: No resource found that matches the given name (at 'id' with value '@id+/button_calculate'). [2011-05-11 16:09:28 - BMICalculator2] res\layout\main.xml:0: エラー: Resource entry main is already defined. [2011-05-11 16:09:28 - BMICalculator2] res\layout\main.out.xml:0: Originally defined here. [2011-05-11 16:09:28 - BMICalculator2] C:\workspace\BMICalculator2\res\values\strings.out.xml:1: エラー: Error parsing XML: no element found [2011-05-11 16:09:28 - BMICalculator2] C:\workspace\BMICalculator2\res\layout\main.out.xml:1: エラー: Error parsing XML: no element found [2011-05-11 16:09:28 - BMICalculator2] C:\workspace\BMICalculator2\res\layout\main.xml:38: エラー: エラー: No resource found that matches the given name (at 'id' with value '@id+/button_calculate'). ソース package com.mamezou.android.bmi.alc; import android.app.Activity; import android.os.Bundle; public class BMICalculatorActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } string.XML <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello.Wopld.BMICalculatorActivity</string> <string name="app_name">BMI Calculator</string> <string name="label_description">BMIを計算します</string> <string name="label_height">身長(cm)</string> <string name="label_weight">体重(kg)</string> <string name="button_calculate">計算</string> </resources> main.XML <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/label_description" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/label_height" /> <EditText android:id="@+id/text_height" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numeric="integer" android:maxLength="3" android:text="160" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/label_weight" /> <EditText android:id="@+id/text_weight" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numeric="integer" android:maxLength="3" android:text="50" /> <Button android:id="@+id/button_calculate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_calculate" /> </LinearLayout>

  • androidプログラムのエラーについて

    自分は今、本を読みながらandroidプログラミングの勉強をしています。 XMLファイルをよく見直して間違いは見当たらないのですが 起動しようとすると「your project contains error」と表示されます。 コンソールには「No resource found that matches the given name (at 'title' with value '@string/menu_settings')」と書いてあります。 ネットで調べたらソースをクリーンすればいいと書いてありましたが クリーンすると今度はjavaファイルにエラーが起きます。 以下が自分が打ち込んだXMLのソースコードです。 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text="お申込みフォーム" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:text="お名前 :" android:layout_width="70sp" android:layout_height="wrap_content"/> <EditText android:id="@+id/name" android:layout_width="200dp" android:layout_height="wrap_content"/> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:text="住所 :" android:layout_width="70sp" android:layout_height="wrap_content"/> <EditText android:id="@+id/address" android:layout_width="200dp" android:layout_height="wrap_content"/> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:text="生年月日 :" android:layout_width="70sp" android:layout_height="wrap_content"/> <Spinner android:id="@+id/month" android:entries="@array/month" android:layout_width="85dp" android:layout_height="wrap_content"/> <TextView android:text="月" android:layout_width="20sp" android:layout_height="wrap_content"/> <Spinner android:id="@+id/day" android:entries="@array/day" android:layout_width="85dp" android:layout_height="wrap_content"/> <TextView android:text="日" android:layout_width="20sp" android:layout_height="wrap_content"/> </LinearLayout> </LinearLayout> どうかよろしくお願い致します。

  • Android用のアプリケーション開発

    私は下記の開発環境でAndroid用のアプリケーションを開発しています。 Eclipse Version: 3.6.2 Android 2.3.3 TableLayoutで3行3列のテーブルの、4行目の3列目と5行目の3列目を結合したいですが出来ませんでした。 下記のソースコードの「あいうえおかきくけ」の部分を画像にして2行分の大きさで表示させたいです。 Android用のアプリケーションの開発が初めてですが、ご教授を頂けると幸いです。 下記はソースコードの一部です。 --------------------------------------- //1行目 TextView text1 = new TextView(this); text1.setText("         "); TextView text2 = new TextView(this); text2.setText("投資情報"); TextView text3 = new TextView(this); text3.setText("         "); TableRow tableRow1 = new TableRow(this); tableRow1.addView(text1); tableRow1.addView(text2); tableRow1.addView(text3); tableLayout.addView(tableRow1, createParam(FP, WC)); //2行目 TextView text4 = new TextView(this); text4.setText("先週の情報"); TableRow tableRow2 = new TableRow(this); tableRow2.addView(text4); tableLayout.addView(tableRow2, createParam(FP, WC)); //3行目 TextView text8 = new TextView(this); text8.setText("2011年11月7日"); text8.setWidth(480); text8.setGravity(Gravity.RIGHT); TableRow tableRow3 = new TableRow(this); TableRow.LayoutParams rowLayout3 = new TableRow.LayoutParams(); rowLayout3.span = 3; tableRow3.addView(text8, rowLayout3); tableLayout.addView(tableRow3, createParam(FP, WC)); //4行目 ImageView image1 = new ImageView(this); image1.setImageResource(R.drawable.tyuugoku); TextView text11 = new TextView(this); text11.setText("国名"); TextView text12 = new TextView(this); text12.setText("あいうえおかきくけ"); TableRow tableRow4 = new TableRow(this); TableRow.LayoutParams rowLayout4 = new TableRow.LayoutParams(); rowLayout4.column = 2; tableRow4.addView(image1); tableRow4.addView(text11); tableRow4.addView(text12); tableLayout.addView(tableRow4, createParam(FP, WC)); //5行目 TextView text13 = new TextView(this); text13.setText("記事リード"); TableRow tableRow5 = new TableRow(this); TableRow.LayoutParams rowLayout5 = new TableRow.LayoutParams(); tableRow5.addView(text13); tableLayout.addView(tableRow5, createParam(FP, WC)); ---------------------------------------- 長文になりましたが、どうぞ宜しくお願い致します。

    • ベストアンサー
    • Java