implement DraggableRow class
This commit is contained in:
parent
21de700d1d
commit
02a5274611
@ -15,7 +15,7 @@ GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout
|
||||
<ch.blinkenlights.android.vanilla.DraggableRow
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -63,4 +63,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
android:layout_height="1px"
|
||||
android:background="@color/divider_color"/>
|
||||
|
||||
</LinearLayout>
|
||||
</ch.blinkenlights.android.vanilla.DraggableRow>
|
||||
|
71
src/ch/blinkenlights/android/vanilla/DraggableRow.java
Normal file
71
src/ch/blinkenlights/android/vanilla/DraggableRow.java
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package ch.blinkenlights.android.vanilla;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.CheckedTextView;
|
||||
import android.widget.Checkable;
|
||||
import android.util.Log;
|
||||
|
||||
public class DraggableRow extends LinearLayout implements Checkable {
|
||||
private boolean mShowCheckBox;
|
||||
private boolean mChecked;
|
||||
private CheckedTextView mCheckBox;
|
||||
|
||||
public DraggableRow(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onFinishInflate() {
|
||||
mCheckBox = (CheckedTextView)this.findViewById(R.id.checkbox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChecked(boolean checked) {
|
||||
mChecked = checked;
|
||||
mCheckBox.setChecked(mChecked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggle() {
|
||||
setChecked(!mChecked);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes the visibility of the checkbox
|
||||
* @param state controlls if the checkbox is shown or hidden
|
||||
*/
|
||||
public void showCheckBox(boolean state) {
|
||||
if (mShowCheckBox != state) {
|
||||
mCheckBox.setVisibility( state ? View.VISIBLE : View.GONE);
|
||||
mShowCheckBox = state;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -87,13 +87,14 @@ public class TabOrderAdapter extends BaseAdapter {
|
||||
@Override
|
||||
public View getView(int position, View convert, ViewGroup parent)
|
||||
{
|
||||
View view;
|
||||
DraggableRow view;
|
||||
if (convert == null) {
|
||||
view = mInflater.inflate(R.layout.draggable_row, null);
|
||||
view = (DraggableRow)mInflater.inflate(R.layout.draggable_row, null);
|
||||
} else {
|
||||
view = convert;
|
||||
view = (DraggableRow)convert;
|
||||
}
|
||||
((TextView)view.findViewById(R.id.text)).setText(LibraryPagerAdapter.TITLES[mTabIds[position]]);
|
||||
view.showCheckBox(true);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user