无法解析方法AttachToListView

时间:2015-10-07 14:04:14

标签: android floating-action-button

我遇到了问题,不知道如何解决。我想给她的fab按钮行为,所以我想使用方法AttachToListView。我在项目“无法解析方法AttachToListView”中收到错误。我怎样才能解决这个问题?我希望得到你的帮助。

public class FragmentListView extends Fragment {
private CreateView cView;
private DatabaseHelper dbHelper;
private BaseManager bAdapter;
private SQLiteDatabase database;
ListView lv;
SwipeRefreshLayout srl;
String TAG = "FragmentListView";
Boolean flag_contextmenu = false;
int item_click;
ActionMode mmode;

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_listview, null);
    String title = getActivity().getResources().getStringArray(R.array.arr_widgets)[4];
    ActivityMain.getInstance().getSupportActionBar().setTitle(title);
    ActivityMain.getInstance().mDrawerToggle.setDrawerIndicatorEnabled(false);
    setHasOptionsMenu(true);

    dbHelper = new DatabaseHelper(getActivity());
    database = dbHelper.getWritableDatabase();
    bAdapter = new BaseManager(getActivity(), database);
    cView = new CreateView(getActivity(), bAdapter);
    lv = (ListView) v.findViewById(R.id.lv_fragmentlistview);
    srl = (SwipeRefreshLayout) v.findViewById(R.id.srl_fragmentlistview);
    CreateListView();
    ListviewClickListener();
    SwipeRefreshListener();
    FloatingActionButton fab = (FloatingActionButton)  v.findViewById(R.id.fab_fragmentlistview);
    fab.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        }
    });

    if(savedInstanceState != null)
    {
        flag_contextmenu = savedInstanceState.getBoolean("flag_contextmenu");
        if (flag_contextmenu =        = true)
    {
        StartContextMenu();
    }
}
fab.AttachToListView(lv);
return v;

}

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
style="@style/AppTheme.window">
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/srl_fragmentlistview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:color="?attr/coloraccent"
    style="@style/AppTheme.window">
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/lv_fragmentlistview"
        android:layout_gravity="right"
        android:headerDividersEnabled="false">
    </ListView>
</android.support.v4.widget.SwipeRefreshLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_fragmentlistview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:layout_margin="16dp"
    android:clickable="true"
    android:src="@drawable/fab_add"
    app:layout_anchor="@id/lv_fragmentlistview"
    app:layout_anchorGravity="bottom|right|end"
    app:layout_behavior="com.softinlife.templatestyles.Views.FAB.FABBehavior">
</android.support.design.widget.FloatingActionButton>
</android.support.design.widget.CoordinatorLayout>

1 个答案:

答案 0 :(得分:0)

是attachToListView而不是AttachToListView。