在我的代码中,我根据数据库值动态创建一些按钮。这些按钮我放在水平滚动视图中。按下每个按钮,我显示一个不同的页面。现在我的问题是从右向左拖动屏幕我们需要显示下一页,下一个按钮也将突出显示,并且从左向右拖动前一个按钮的页面应该显示,该按钮应该突出显示。
我的代码是:
Cursor c = sqldb.rawQuery("select Diameter from ProductDetailMetric where ProductId=1", null);
n=c.getCount();
arr = new String[c.getCount()];
int i = 0;
for (c.moveToPosition(-1); c.moveToNext(); c.isAfterLast()) {
arr[i] = c.getString(0);
Log.e("","no.of values----"+"--"+arr[i]);
i++;
}
}
}
catch(Exception e){
System.out.println(e.toString());
}
ll=(LinearLayout)findViewById(R.id.lll);
for(int i=0;i<arr.length;i++){
final Button b=new Button(this);
b.setWidth(80);
b.setText(arr[i]);
ll.addView(b);
b.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
b.getText();
Log.e("","value---"+b.getText());
Cursor c1 = sqldb.rawQuery("select *from ProductDetailMetric where Diameter="+b.getText()+" and ProductId=1", null);
for (c1.moveToPosition(-1); c1.moveToNext(); c1.isAfterLast()) {
Log.e("","value---0"+c1.getString(0));
Log.e("","value---1"+c1.getString(1));
Log.e("","value---2"+c1.getString(2));
Log.e("","value---3"+c1.getString(3));
Log.e("","value--4-"+c1.getString(4));
Log.e("","value---5"+c1.getString(5));
e1.setText(c1.getString(8));
e2.setText(c1.getString(9));
e3.setText(c1.getString(10));
e4.setText(c1.getString(11));
e5.setText(c1.getString(12));
e6.setText(c1.getString(13));
e7.setText(c1.getString(14));
e8.setText(c1.getString(15));
e9.setText(c1.getString(16));
e10.setText(c1.getString(17));
}
}
});
}
答案 0 :(得分:0)