1. To place the image file into res/drawable in Android Studio.




2. To write the activity_main.xml

package com.example.test.ecap;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.widget.ImageView;public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        findViews();        secondImage.setImageResource(R.drawable.dbpath);    }    @Override    public boolean onCreateOptionsMenu(Menu menu) {        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.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();        //noinspection SimplifiableIfStatement        if (id == R.id.action_settings) {            return true;        }        return super.onOptionsItemSelected(item);    }    private ImageView secondImage;    private void findViews() {        secondImage = (ImageView) findViewById(R.id.imageView);    }}






更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 使用VS2015调试Android的C++动态链接库
  2. Intent及其属性详解
  3. android api code学习之ActivityManager
  4. Android(安卓)开发经验汇总
  5. Android之EventBus1.0 和EventBus3.0的使
  6. android 命令
  7. iOS开发 OC与java相对应的3DES加解密
  8. Google Android如何分析和研究Log文件 ,如
  9. Kivy A to Z -- 如何从python代码中直接
  10. [置顶] android popupwindow 弹出窗口在