무료 또는 유료 앱 등을 보려면 왼쪽/오른쪽으로 스크롤 할 수있는 안드로이드 마켓과 유사한 기능을하는 갤러리를 만들려고합니다. 또한 레이아웃을 위아래로 스크롤 할 수 있습니다.레이아웃 갤러리를 만들 때 텍스트가 어두워 짐 (초기)
지금까지 간단히 "Hello World!"라는 레이아웃을 두 개로드했습니다. 텍스트보기 및 "이봐! 너 어떠니?" 텍스트보기.
처음에는 갤러리의 위치 0에있는 텍스트가 화면을 벗어날 때까지 어두워 진다는 점을 제외하고는로드가 잘됩니다. 내가 누락 된 것이 있습니까?
public class HelloGallery extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Gallery gallery = (Gallery)findViewById(R.id.gallery);
gallery.setAdapter(new ViewAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
Toast.makeText(HelloGallery.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
}
}
public class ViewAdapter extends BaseAdapter
{
public Context mContext;
public static final Integer[] viewId = { R.layout.helloworld, R.layout.heyhowareyou };
public int mGalleryItemBackground;
public ViewAdapter(Context context)
{
this.mContext = context;
TypedArray attr = context.obtainStyledAttributes(R.styleable.HelloGallery);
mGalleryItemBackground = attr.getResourceId(R.styleable.HelloGallery_android_galleryItemBackground, 0);
attr.recycle();
}
@Override
public int getCount()
{
return viewId.length;
}
public Object getItem(int position)
{
return position;
}
public long getItemId(int position)
{
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
convertView = LayoutInflater.from(mContext).inflate(viewId[position], null);
convertView.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
convertView.setBackgroundResource(mGalleryItemBackground);
return convertView;
}
}
나는 이것을 조금 참조했다. Get button to work in gallery with inflated layouts
어떤 도움을 :하고있는이 스레드에 어떤 Aavon는
스레드 링크 ... 내가 얻을려고 정확히 무엇입니까?
미리 감사드립니다.