gpt4 book ai didi

android - 安卓杂志架

转载 作者:行者123 更新时间:2023-11-29 22:04:02 25 4
gpt4 key购买 nike

我必须创建一个应用程序的 UI 作为存放杂志的架子。我正在使用自定义 GridView ,网格元素由具有货架的杂志缩略图组成作为背景图像。

架子.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="4" >
</GridView>

</LinearLayout>

项目.xml

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/grid">

<ImageView
android:id="@+id/imageView1"
android:layout_width="70dp"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="41dp"
android:src="@drawable/book1" />

</RelativeLayout>

图书馆 Activity .java

public class LibraryActivity extends Activity {

GridView grid = null;
ArrayList<Integer> image = new ArrayList<Integer>();
ImageView thumbnail;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.shelf);
image.add(R.drawable.book1);
image.add(R.drawable.book2);
image.add(R.drawable.book3);
image.add(R.drawable.book4);

System.out.println("before adapter");
grid = (GridView) findViewById(R.id.gridView1);
CustomAdapter adapter = new CustomAdapter(this, R.layout.item);
grid.setAdapter(adapter);
}

public class CustomAdapter extends BaseAdapter {

Context mContext = null;
int mitem = 0;
LayoutInflater mInflater = null;

public CustomAdapter(Context context, int item) {

this.mContext = context;
this.mitem = item;
this.mInflater = (LayoutInflater) context
.getSystemService(LAYOUT_INFLATER_SERVICE);

}

@Override
public int getCount() {
// TODO Auto-generated method stub
return image.size();
}

@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}

@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

if (convertView == null) {

System.out.println("****CHECKING 2**********");
convertView = mInflater.inflate(mitem, null);
System.out.println("****CHECKING 3**********");
thumbnail = (ImageView) convertView
.findViewById(R.id.imageView1);
System.out.println("****CHECKING 3**********");

}

thumbnail.setImageResource(image.get(position));

return convertView;
}

}

}

但是使用此代码仅显示带有杂志的架子。我想显示空架子以占据设备的整个屏幕。我怎样才能做到这一点??是否有任何替代方法来实现货架??

最佳答案

有一个很棒的项目叫做 Shelves由 Google 的 Romain Guy 制作。你应该检查一下。

关于android - 安卓杂志架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11244937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com