android:layout_height="fill_parent"
>
<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1">
- <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
+ <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="0px">
<LinearLayout android:id="@+id/settingLayout" android:padding="6px" android:layout_margin="3px" android:background="#666666" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:text="@+string/date_title" android:background="#ccffff" android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
<TextView android:id="@+id/settingMessage" android:padding="10px" android:text="@+string/selectTitle" android:background="#ffff66" android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
</LinearLayout>
- <TextView android:text="@+string/date_title" android:background="#99cccc" android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
- <Button android:text="ユーザ/パスワードを設定する" android:id="@+id/settingUserButton" android:layout_width="fill_parent" android:layout_height="wrap_content" />
- <TextView android:text="@+string/date_title" android:background="#99cccc" android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
- <Button android:text="送信先のノートを設定する" android:id="@+id/settingNoteButton" android:layout_width="fill_parent" android:layout_height="wrap_content" />
- <TextView android:text="@+string/date_title" android:background="#99cccc" android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView>
- <Button android:text="ヘッダーを設定する" android:id="@+id/settingHeaderButton" android:layout_width="fill_parent" android:layout_height="wrap_content" />
+ <TextView android:text="@+string/date_title" android:background="#99cccc" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0px"></TextView>
+ <Button android:text="ユーザ/パスワードを設定する" android:id="@+id/settingUserButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0px" />
+ <TextView android:text="@+string/date_title" android:background="#99cccc" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0px"></TextView>
+ <TextView android:text="@+string/date_title" android:background="#cc99cc" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0px"></TextView>
+ <Button android:text="送信先のノートを設定する" android:id="@+id/settingNoteButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0px" />
+ <TextView android:text="@+string/date_title" android:background="#99cccc" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0px"></TextView>
+ <Button android:text="ヘッダーを設定する" android:id="@+id/settingHeaderButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0px" />
</LinearLayout>
</ScrollView>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
import java.util.List;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
-import android.widget.Checkable;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.yuji.em.data.Note;
import com.yuji.em.data.NoteDao;
import com.yuji.em.utility.BaseActivity;
+import com.yuji.em.utility.EditPrefUtil;
public class SelectNoteListActivity extends BaseActivity {
+ private EditPrefUtil pref = new EditPrefUtil(this);
private LinearLayout messageLayout = null;
private TextView titleView = null;
private TextView messageView = null;
private Button yesButton;
private Button noButton;
private ListView selectListView;
-
- private View prevListView = null;
- private int selectedIndex = -1;
private boolean isEmpty = true;
+ private static int selectedIndex = -1;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
});
- // float fSize = titleView.getTextSize();
- // messageView.setTextSize((float) (fSize * 1.0));
-
- // #27899 TODO
+ // #27899
selectListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
- // selectListView.setItemsCanFocus(false);
- // selectListView.setFocusable(true);
- // selectListView.setFocusableInTouchMode(true);
updateList();
-
+ selectedIndex = pref.getInt(Constant.PREF_NOTE_INDEX);
setStatus(null);
}
- // TODO
-// @Override
-// public void onStart(){
-// super.onStart();
-// selectListView.clearChoices();
-// }
-
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
+ init(this);
updateList();
setStatus(null);
}
}
+ @Override
+ protected void onStart(){
+ super.onStart();
+
+ selectedIndex = pref.getInt(Constant.PREF_NOTE_INDEX);
+ }
+
+ @Override
+ protected void onPause() {
+ pref.put(Constant.PREF_NOTE_INDEX, selectedIndex);
+ pref.update();
+
+ super.onPause();
+ }
+
private void updateList() {
NoteDao dao = NoteDao.getInstance();
List<Note> list = dao.search(this);
- // ArrayAdapter<Note> adapter = new ArrayAdapter<Note>(this,
- // android.R.layout.simple_list_item_1, list);
ArrayAdapter<Note> adapter = new ArrayAdapter<Note>(this,
R.layout.simple_list_item_2, R.id.text3, list);
selectListView.setAdapter(adapter);
-
-// int size = selectListView.getChildCount();
-// for (int i = 0; i < size; i++){
-// Checkable v = (Checkable)selectListView.getChildAt(i);
-// v.setChecked(false);
-// }
- selectedIndex = -1;
isEmpty = dao.isEmpty(list);
}
protected void selectListViewOnItemClick(AdapterView<?> parent, View view,
int position, long id) {
-
- if (view == prevListView) {
- return;
- }
- // #27594
- // if (prevListView != null) {
- // prevListView.setBackgroundColor(Color.WHITE);
- // }
- // view.setBackgroundColor(0xffccffcc);
- prevListView = view;
-
selectedIndex = position;
setStatus(parent);
}
private void editButtonOnClick() {
- if (prevListView == null || selectedIndex < 0) {
+ if (selectedIndex < 0) {
return;
}
}
private void yesButtonOnClick() {
+ if (selectedIndex < 0) {
+ return;
+ }
+
NoteDao dao = NoteDao.getInstance();
Note note = new Note("", "");
dao.update(this, note, selectedIndex);
setStatus(noButton);
}
+ private boolean isSelected() {
+ return selectedIndex >= 0;
+ }
+
private void setStatus(View view) {
if (view == null) {
if (isEmpty) {
messageView.setText("\91\97\90M\90æ\82Ì\83m\81[\83g\82ð\90Ý\92è\82·\82é\82É\82Í\81A\83\8a\83X\83g\82ð\91I\91ð\82µ\81A\81u\8dX\90V\81v\83{\83^\83\93\82ð\89\9f\82µ\82Ä\82\82¾\82³\82¢\81B"); // TODO
selectListView.setEnabled(true);
editButton.setVisibility(View.VISIBLE);
- //editButton.setEnabled(false);
- editButton.setEnabled(selectListView.getCheckedItemPosition() >= 0);
+ editButton.setEnabled(isSelected());
deleteButton.setVisibility(View.VISIBLE);
deleteButton.setEnabled(false);
yesButton.setVisibility(View.GONE);
: View.GONE);
selectListView.setEnabled(true);
editButton.setVisibility(View.VISIBLE);
- //editButton.setEnabled(false);
- editButton.setEnabled(selectListView.getCheckedItemPosition() >= 0);
+ editButton.setEnabled(isSelected());
deleteButton.setVisibility(View.VISIBLE);
deleteButton.setEnabled(false);
yesButton.setVisibility(View.GONE);
messageLayout.setVisibility((isEmpty) ? View.VISIBLE : View.GONE);
selectListView.setEnabled(true);
editButton.setVisibility(View.VISIBLE);
- //editButton.setEnabled(true);
- editButton.setEnabled(selectListView.getCheckedItemPosition() >= 0);
+ editButton.setEnabled(isSelected());
Note item = (Note) selectListView.getItemAtPosition(selectedIndex);
deleteButton.setVisibility(View.VISIBLE);
deleteButton.setEnabled(!CommonUtil.isNull(item.getTitle()));
setStatus(selectListView);
}
}
+
+ public static void init(Context context){
+ EditPrefUtil pref = new EditPrefUtil(context);
+ pref.put(Constant.PREF_NOTE_INDEX, -1);
+ pref.update();
+
+ selectedIndex = -1;
+ }
}