2016-06-14 3 views
-1

私の活動のタイトルを編集可能にするのに役立つ人はいますか?私は追加したい特定のメモにタイトルを追加できるようにするため、このメモをアプリに持っています。 Manifest.xmlのラベルとしてメニューからEditTextのIDを使用しようとしましたが、動作しません。あなたの活動における自身でメニューのアンドロイドのアクティビティタイトルを編集可能にするにはどうすればいいですか?

サンプルコード

<?xml version="1.0" encoding="utf-8"?> 
<menu 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 

    <item 
     android:title="Ok" 
     android:icon="@drawable/ic_done_white_48dp" 
     android:id="@+id/note_details_save" 
     app:showAsAction="always"/> 

    <item 
     android:title="back" 
     android:icon="@drawable/ic_back_button" 
     android:id="@+id/note_details_back" 
     android:orderInCategory="0" 
     app:showAsAction="always"/> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/note_details_title"/> 

</menu> 
+0

チェックこの:https://developer.android.com/ reference/android/app/Activity.html#setT itle%28java.lang.CharSequence%29 –

答えて

0

利用のsetTitle( "マイタイトル")。

「私のタイトル」はあなたのeditTextの内容でなければなりません。

String title = et.getText().toString(); 
0

のstyles.xml

<resources> 
    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar"> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 
</resources> 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:background="@color/colorPrimary" 
     android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" 
     android:elevation="8dp" app:elevation="8dp"> 
     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:inputType="textPersonName" 
      android:paddingLeft="10dp" 
      android:text="@string/app_name" 
      android:ems="10" 
      android:id="@+id/editText2" 
      android:layout_weight="1" /> 
    </LinearLayout> 
</android.support.constraint.ConstraintLayout> 

Editable title

関連する問題