현재 구상중인 레이아웃이 이와 같습니다.
A,B는 그리드 뷰로 이미지를 확인 하고
이와 같은 전체적 레이아웃을 스크롤 뷰로 지정하고 싶습니다.
출발일, 도착일 변경은 현재 버튼으로 해놓았지만 최종적으로는
달력이미지를 띄워 놓고 해당 일자를 클릭했을 시 text로 표현 하려 합니다.
총 약 4개 정도의 커다란 레이아웃(출발일 달력, 도착일 달력, A그리드뷰, B그리드뷰)을
스크롤뷰를 통하여 이동시키고 싶은데 그리드뷰와 스크롤 뷰가 중첩되니 오류가 발생합니다.
해결방법이 있을까요?? 고수님들 도와주세요 ㅜ
아. 그리고 A,B그리드뷰 크기를 고정시키려면 어떻게 해야할까요?
마지막으로 달력을 제가 원하는 그림의 달력을 넣기 위해서는
달력을 직접 만들어야 하나요??
=========================layout 소스 (.xml)=========================
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/btn_leave_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="mOnClick"
android:text="출발일 변경" />
<TextView
android:id="@+id/leavedate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="levdate"
android:textSize="20sp" />
<Button
android:id="@+id/btn_arrive_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="mOnClick"
android:text="도착일 변경" />
<TextView
android:id="@+id/arrivedate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="arrdate"
android:textSize="20sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btn_A"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="mOnClick"
android:text="A" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</LinearLayout>
<GridView
android:id="@+id/levgridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnWidth="85dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" >
</GridView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="20dp" >
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btn_B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="mOnClick"
android:text="B" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</LinearLayout>
<GridView
android:id="@+id/arrgridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnWidth="85dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" >
</GridView>
</LinearLayout>
</LinearLayout>
</ScrollView>
=============================.java==========================================
package kr.booknair.pypproto;
import java.util.Calendar;
import java.util.GregorianCalendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.DatePicker;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class FlightDate extends Activity {
int leaYear, leaMonth, leaDay, arrYear, arrMonth, arrDay;
TextView levdate;
TextView arrdate;
GridView levgridview;
GridView arrgridview;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.flight_date);
levgridview=(GridView)findViewById(R.id.levgridview);
levgridview.setAdapter(new ImageAdapters(this));
arrgridview=(GridView)findViewById(R.id.arrgridview);
arrgridview.setAdapter(new ImageAdapters(this));
levdate = (TextView) findViewById(R.id.leavedate);
arrdate = (TextView) findViewById(R.id.arrivedate);
Calendar leacal = new GregorianCalendar();
leaYear = leacal.get(Calendar.YEAR);
leaMonth = leacal.get(Calendar.MONTH);
leaDay = leacal.get(Calendar.DAY_OF_MONTH);
Calendar arrcal = new GregorianCalendar();
arrYear = arrcal.get(Calendar.YEAR);
arrMonth = arrcal.get(Calendar.MONTH);
arrDay = arrcal.get(Calendar.DAY_OF_MONTH);
UpdateNow();
}
public void mOnClick(View v) {
int id = v.getId();
if (id == R.id.btn_leave_date) {
new DatePickerDialog(this, leaDateSetListener, leaYear, leaMonth,
leaDay).show();
} else if (id == R.id.btn_arrive_date) {
new DatePickerDialog(this, arrDateSetListener, arrYear, arrMonth,
arrDay).show();
}
}
DatePickerDialog.OnDateSetListener leaDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
leaYear = year;
leaMonth = monthOfYear;
leaDay = dayOfMonth;
UpdateNow();
}
};
DatePickerDialog.OnDateSetListener arrDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
arrYear = year;
arrMonth = monthOfYear;
arrDay = dayOfMonth;
UpdateNow();
}
};
void UpdateNow() {
levdate.setText(String
.format("%d/%d/%d", leaYear, leaMonth + 1, leaDay));
arrdate.setText(String
.format("%d/%d/%d", arrYear, arrMonth + 1, arrDay));
}
}
class ImageAdapters extends BaseAdapter{
private Integer[]image={
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
};
Context mcontext;
public ImageAdapters(Context context){
mcontext=context;
}
@Override
public int getCount(){
//TODO Auto-generated method stub
return image.length;
}
@Override
public Object getItem(int arg0){
//TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int arg0){
//TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int arg0, View arg1,ViewGroup arg2){
ImageView imageview = new ImageView(mcontext);
imageview.setLayoutParams(new GridView.LayoutParams(85,85));
imageview.setScaleType(ImageView.ScaleType.FIT_XY);
imageview.setImageResource(image[arg0]);
System.out.println(image[arg0]);
return imageview;
}
}