我有一個滾動視圖,它可以在滾動視圖中創建數據庫和圖像視圖中的圖像。動態創建。我想在選擇其中一個圖像時顯示在另一個活動或更大的活動上。如何在水平滾動視圖中製作可點擊的圖像?
這是我的代碼:
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();
}
RecyclerView不eclipse.is有一個特殊的lib? –
@shayan talaei是的,你需要使用Android支持庫v7 for Recycler。你可以在你的sdk文件夾中找到它。你只需要在eclipse中導入並使用它。 – SANAT