膨胀视图无法正常工作

时间:2014-11-19 07:28:18

标签: android

我使用了futureimple的FloatingActionMenu。 https://github.com/futuresimple/android-floating-action-button

 <com.getbase.floatingactionbutton.FloatingActionsMenu
            xmlns:fab="http://schemas.android.com/apk/res-auto"
            android:id="@+id/floatingbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layoutDirection="rtl"
            android:layout_alignParentBottom="true"
            fab:fab_plusIconColor="@color/white"
            fab:fab_colorNormal="#0277bd"
            fab:fab_colorPressed="@color/pink"/>

活动代码:

  add_item_button = (FloatingActionsMenu)findViewById(R.id.floatingbutton);
    view = View.inflate(this, R.layout.view_1, null);
    add_item_button.addView(view);
    add_item_button.canResolveLayoutDirection();
    add_item_button.callOnClick();

    task = (TextView)view.findViewById(R.id.reminder);
    note = (TextView)view.findViewById(R.id.notee);
    bday = (TextView)view.findViewById(R.id.bday);

    task.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            view.clearFocus();
            add_item_button.collapse();
            FragmentManager fm = getFragmentManager();
            FragmentTransaction ft;
            add_task_frag aTF = new add_task_frag();
            ft = fm.beginTransaction();
            ft.setCustomAnimations(R.anim.slide_up, R.anim.slide_down, R.anim.slide_up, R.anim.slide_down);
            ft.addToBackStack("aTF").replace(R.id.MainContent, aTF, "aTF");
            ft.commit();
        }
    });
    note.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            view.clearFocus();
            add_item_button.collapse();
            FragmentManager fm = getFragmentManager();
            FragmentTransaction ft;
            add_note_frag aNF = new add_note_frag();
            ft = fm.beginTransaction();
            ft.setCustomAnimations(R.anim.slide_up, R.anim.slide_down, R.anim.slide_up, R.anim.slide_down);
            ft.addToBackStack("aNF").replace(R.id.MainContent, aNF, "aNF");
            ft.commit();
        }

现在,当我单击浮动按钮时,会单击其中一个文本视图(任务,注释和bday)而不是按钮。有什么想法在这里发生吗?

我正在膨胀的观点:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp">

<TextView
       android:id="@+id/reminder"
       android:padding="5dp"
       android:layout_width="wrap_content"
       android:textColor="@color/background_floating_material_light"
       android:layout_height="wrap_content"
       android:text="Add Task"
       android:textSize="18dp"
       android:background="@drawable/blue_rectangle"/>

<TextView
    android:id="@+id/notee"
    android:layout_marginTop="10dp"
    android:layout_below="@+id/reminder"
    android:padding="5dp"
    android:layout_width="wrap_content"
    android:textColor="@color/background_floating_material_light"
    android:layout_height="wrap_content"
    android:text="Add Note"
    android:textSize="18dp"
    android:background="@drawable/blue_rectangle"/>

<TextView
    android:layout_marginTop="10dp"
    android:layout_below="@+id/notee"
    android:id="@+id/bday"
    android:padding="5dp"
    android:layout_width="wrap_content"
    android:textColor="@color/background_floating_material_light"
    android:layout_height="wrap_content"
    android:text="Add B'day"
    android:textSize="18dp"
    android:background="@drawable/blue_rectangle"/>

</RelativeLayout>

0 个答案:

没有答案