【发布时间】:2015-09-04 08:42:07
【问题描述】:
我有一个滚动视图,它提供来自数据库的图像,并在滚动视图中动态创建图像视图。我想在选择它显示在另一个活动或更大的图像时。
这是我的代码:
public class MainActivity extends Activity{
private DatabaseH db;
private Bitmap[] ax;
ImageView im;
int i;
String table="main";
String noeDastor="کار با فایل";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
db = new DatabaseH(this);
db.useable();
refresher();
LinearLayout yourLayout = (LinearLayout)findViewById(R.id.ll1);
for ( i = 0; i < ax.length; i++) {
im=new ImageView(getApplicationContext());
im.setImageBitmap(ax[i]);
yourLayout.addView(im,700,500);
}
OnClickListener on=new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.putExtra("integer", i);
intent.putExtra("table", table);
intent.putExtra("noeDastor", noeDastor);
startActivity(intent);
}
};
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
private void refresher(){
db.open();
int save = db.shomaresh_field(table,noeDastor);
ax = new Bitmap[save];
for (int i = 0; i <save; i++) {
ax[i] = db.retrive(table,noeDastor,i);
}
db.close();
}
【问题讨论】:
标签: android scrollview items