我需要通过从其他活动中选择图像来动态更改活动的背景.并将所选图像传递回调用活动,但是当我尝试获取图像时,它为空.这是我的代码.
public class SelectGoalBackground extends OrmLiteBaseActivity<DatabaseHelper> {// implements{
GridView gridview ;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.select_goal_background);
final String from = getIntent().getExtras().getString("from");
goalsList = new ArrayList<Goal>();
try {
goalsList = getTop3Goals();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (java.sql.SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
ImageView l = (ImageView)gridview.getChildAt(position);
Drawable …Run Code Online (Sandbox Code Playgroud)