gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(HelloGridView.this, "" + position, Toast.LENGTH_SHORT).show();
}
});
Run Code Online (Sandbox Code Playgroud) 任何人都可以告诉我如何调整imageButton的大小以使图像精确拟合.这是我尝试的代码,但图像放置在我定位的位置,
imageButton但我无法减小imageButton的大小,请帮我纠正这个问题...我试过的代码是......
<ImageButton>
android:id="@+id/Button01"
android:scaleType="fitXY" // i have tried all the values for this attr
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cropToPadding="false"
android:paddingLeft="10dp"
android:src="@drawable/eye"> // this is the image(eye)
</ImageButton>
Run Code Online (Sandbox Code Playgroud) 我是android的新来者而不是java.我一直在通过XML文件在android中设计UI,在那个页面我有3个线性布局,在我的顶部布局(第一个LinearLayout)我保留了一些图像,在最后的布局中我保留了一些按钮,现在我需要放置一个在我的中心布局中使用canvas的圆圈(红色),我已经编写了一个单独的类,它扩展了View在onDraw(Canvas画布)中的位置,我画了一个圆圈.
package com.project.TargetTrackr3;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
public class DrawCanvasCircle extends View{
public DrawCanvasCircle(Context mContext) {
super(mContext);
}
public void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
canvas.drawColor(Color.WHITE);
paint.setColor(Color.BLUE);
canvas.drawCircle(20, 20, 15, paint);
}
}
现在我必须将这个画布带到第二个布局,我的main.xml如下所示
package com.project.TargetTrackr3;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
public class TargetTrackr3Activity extends Activity {
/** Called when the activity is first created. */
protected LinearLayout ll; … 如何使用GZip压缩和解压缩android中的文件.请提供一些参考,以便对我有很大的帮助.
提前致谢
任何人都可以给我一个关于如何从Android应用程序中的OBD II蓝牙适配器读取值的想法.
我想从我的Android应用程序扫描蓝牙设备开始,然后在找到蓝牙设备后,我将如何与它进行交互并从中获取值?
我正在使用BroadcastReceiver来检查我的应用程序运行时的网络连接.我已经使用Activity绑定了BroadcastReceiver以便在连接断开时带来一些像AlertDialog这样的控件.但现在我不想将此接收器限制为特定的活动,而是我希望将其应用于我的整个应用程序(所有活动).那么我应该采取什么方式来完成这项工作......
这是我用过的代码.请让我知道我的代码是否符合标准,如果出错了,请纠正我.
package com.xx.mobile;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
public class CheckforConnectivity extends Activity {
private static final String LOG_TAG = CheckforConnectivity.class.getSimpleName();
static final String ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
private boolean mActiveNetState = false;
private boolean mMobileNetState = false;
private boolean mStatus = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IntentFilter filter = new IntentFilter(ACTION);
this.registerReceiver(ConnectivityCheckReceiver, filter);
}
@Override
protected void …Run Code Online (Sandbox Code Playgroud) 我画了几个同心圆,并在同一个视图上添加了一个手势监听器.我画了一个点,我正在放置标记并点击下面的按钮.一旦我点击按钮,我将获得放置制造商的位置的(x,y)坐标并单击按钮.现在我必须找出视图的中心(x,y)和我之前做过的标记之间的距离.我尝试使用距离计算表格ula,但我仍然不确定我是否得到了正确的解决方案.这是因为,例如,当我在圆的顶部标记一个点并在圆的底部做出标记时,它给出不同的值.由于所有都是圆圈,从中我标记的圆圈的一部分,它必须给我相同的距离.我对吗 ?
我尝试了很多想法,但仍然没有任何效果.
我也附上了那个页面的屏幕截图,请看一下

任何帮助都是值得赞赏的.
谢谢.
我试图通过Android应用程序从SQLiteDB中删除记录,这是我使用代码删除记录的方式
//Snippet of code in my DBAdapter Class
public boolean DeleteRecord(String ContactName) {
Log.i(TAG, "DeleteRecord(String ContactName)");
Log.i(TAG, ContactName);
return db.delete(TABLE_SIMPLETABLE_CLIENT1,KEY_EMPLOYEE_NAME + "="
+ContactName,null);
}
从另一个类,我试图通过打开数据库并调用此方法并再次关闭数据库来调用此方法,这就是我编码的方式,
//我的DBApplication类中的代码片段
public void onClick(DialogInterface dialog,
int which) {
DBAdapter.open();
DBAdapter.DeleteRecord(DeleteRecord);
//DeletRecord is string value that in DB(Sivaram)
DBAdapter.close();
}
当我部署它时,我得到以下错误,
08-25 14:52:20.602: ERROR/AndroidRuntime(231): android.database.sqlite.SQLiteException: no such column: Sivaram: , while compiling: DELETE FROM SimpleTable1 WHERE Employee_Name=Sivaram
找到解决方案,请帮助我
提前致谢...
android ×9
autostart ×1
bluetooth ×1
canvas ×1
connectivity ×1
gzip ×1
imagebutton ×1
networking ×1
obd-ii ×1
points ×1
sqlite ×1