我的任务是将干净滚动到另一个屏幕,然后按下图标并显示弹出窗口,我想用来ViewPager在两个页面之间进行干净滚动(滑动),然后Dialog用来显示弹出窗口,我找不到任何工作关于如何ViewPager在两个布局之间实现的示例,有人有工作样本吗?
谢谢.大卫
我知道在Android中不可能水平滚动网格视图.但我正在做的是在水平滚动视图中动态添加图像按钮,如下所示:
public class HorizontalScroller extends Activity {
static int l=0;
private Rect mTempRect = new Rect();
static int r1=0;
static int t=0;
static int b=0;
static int x=0;
static int y=0;
//Button[] b1 = new Button[100];
ImageButton btn[][] = new ImageButton[10][10];
//ImageButton b1 = new ImageButton(this);
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout rl = (LinearLayout)findViewById(R.id.widget92);
LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
for(int i=0;i<4;i++)
{
for(int j=0;j<10;j++)
{System.out.println("helo");
/* l=l+100; …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中有一个网格视图,我需要水平滚动它.我已经尝试将gridview更改为gallery.But然后只有一行可用,但我需要不同的行,如在网格视图中.所以基本上我需要的是一个可以水平滚动的网格视图.有没有有效的方法来做到这一点?提前谢谢.
问候Anu
嗨,感谢您的回复.我尝试使用Gallery并实现了一个在其getView方法中提供多视图的适配器.
我的java文件是:
public class Gridview extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setAdapter(new GridAdapter(this));
g.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
Toast.makeText(Gridview.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
}
public class GridAdapter extends BaseAdapter {
int mGalleryItemBackground;
private Context mContext;
private Integer[] mImageIds = {
R.drawable.icon,
R.drawable.icon,
R.drawable.icon,
R.drawable.icon,
R.drawable.icon,
R.drawable.icon,
R.drawable.icon,
};
public GridAdapter(Context c) {
mContext = c;
TypedArray a …Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中使用viewpager.我试图在一个月内每天都这样做,但我无法实现解决方案.我想创建具有相同listview概念但不同数据的页面.这是我的代码:
public final class TestFragment extends ListFragment {
private static final String KEY_CONTENT = "TestFragment:Content";
ArrayList <HashMap<String, Object>> imageliste = new ArrayList<HashMap<String, Object>>();
public class MyCustomAdapter extends ArrayAdapter<HashMap<String, Object>> {
//Bitmap bm;
public MyCustomAdapter(Context context, int textViewResourceId,
ArrayList<HashMap<String,Object>> imageliste) {
super(context, textViewResourceId,imageliste);
// TODO Auto-generated constructor stub
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//return super.getView(position, convertView, parent);
View row = convertView;
if(row==null){
LayoutInflater inflater=LayoutInflater.from(getActivity());
row=inflater.inflate(R.layout.list, parent, false);
}
TextView label=(TextView)row.findViewById(R.id.text1); …Run Code Online (Sandbox Code Playgroud)