我正在尝试逐像素显示位图图像(这明确意味着有一些延迟)。
为此,我使用两个“for 循环”,但它只打印单行像素......
我的代码:
Button start = (Button) findViewById(R.id.start);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Toast.makeText(getBaseContext(), "Printing...", Toast.LENGTH_SHORT).show();
iImageArray = new int[bMap.getWidth()* bMap.getHeight()]; //initializing the array for the image size
bMap.getPixels(iImageArray, 0, bMap.getWidth(), 0, 0, bMap.getWidth(), bMap.getHeight()); //copy pixel data from the Bitmap into the 'intArray' array
//Canvas canvas = new Canvas (bMap);
//replace the red pixels with yellow ones
for (int i=0; i < bMap.getHeight(); i++) {
for(int j=0; j<bMap.getWidth(); j++) {
iImageArray[j] = 0xFFFFFFFF;
} …Run Code Online (Sandbox Code Playgroud) 我有两个活动,根据SD卡的存在打开.一个活动有三个Buttons和TextView,另一个是ImageView,一个按钮和变焦控制.当我改变方向时,按钮在水平方向上被扰乱.如何解决这个问题?
我的'SD'卡布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1E1E1E"
android:orientation="vertical" >
<Button
android:id="@+id/button_print"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="44dp"
android:background="@drawable/my_button"
android:text="@string/print" />
<TextView
android:id="@+id/text_SDmissing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:text="@string/SDmissing"
android:textSize="20dp" />
<Button
android:id="@+id/button_camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button_print"
android:layout_centerHorizontal="true"
android:layout_marginBottom="58dp"
android:background="@drawable/my_button"
android:text="@string/camera" />
<Button
android:id="@+id/button_insert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_SDmissing"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="@drawable/my_button"
android:text="@string/insert" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我需要实现已经存在于android中的sd卡删除通知,我需要知道它是如何完成的?任何示例代码或教程都会有很大帮助.
我正在为我的应用程序使用标准gridview源.我面临的问题是,当我在网格视图中滚动图像时,图像每次都会动态变化,在位置上有错误的图像.以下是我使用的代码......
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Set up an array of the Thumbnail Image ID column we want
String[] projection = {MediaStore.Images.Thumbnails._ID};
// Create the cursor pointing to the SDCard
cursor = managedQuery( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
projection, // Which columns to return
null, // Return all rows
null,
MediaStore.Images.Thumbnails.IMAGE_ID);
// Get the column index of the Thumbnails Image ID
columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
GridView gridView = (GridView) findViewById(R.id.gridview);
gridView.setAdapter(new ImageAdapter(this));
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View …Run Code Online (Sandbox Code Playgroud) 我正在通过startActivityForResult()从gallery加载图像并在onActivity()中加载图像.我不能为该图像实现touchlistener吗?供参考见下文.
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == SELECT_PICTURE) {
......
......
Bitmap bitmapPreview = BitmapFactory.decodeFile(fileSrc); //load preview image
setimage.setImageBitmap(BitmapPreview);
setimage.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(getApplicationContext(), "Image touced!", Toast.LENGTH_SHORT).show();
return true;
}
});
Run Code Online (Sandbox Code Playgroud)