2016-06-14 2 views
-1

누군가 내 활동 제목을 편집 가능하게 만들 수 있습니까? 내가 추가하려는 특정 메모에 제목을 추가 할 수 있도록하려는이 메모가 앱에 있습니다. 메뉴의 EditText의 ID를 Manifest.xml의 레이블로 사용하려고 시도했지만 작동하지 않습니다. 당신의 활동 자체 메뉴android activity title을 (를) 편집 가능하게 만드는 방법은 무엇입니까?

<?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

관련 문제