Android屏幕底部的黑色导航栏无法轻松移除.它从3.0开始就是Android的一部分,作为硬件按钮的替代品.这是一张图片:

如何获得此UI元素的宽度和高度的大小(以像素为单位)?
我用按钮创建了一个应用程序,并为该按钮编写了onClickListener.我已经尝试了几个示例代码示例,但没有一个有效.他们都带来了Android相机应用程序,不拍照.我想要一些代码可以放在我的onClickListener中,所以当我按下屏幕上的按钮时,会拍摄一张照片.
当我在Android活动中按下按钮时,如何让相机拍照?
如何在SQLite数据库中存储JSON对象?什么是正确的方法?
一个地方是blob类型列.如果我可以将JSON对象转换为字节数组并使用Fileoutputstream
另一个想法是将文本列存储为String
import org.json.JSONObject;
JSONObject jsonObject;
public void createJSONObject(Fields fields) {
jsonObject = new JSONObject();
try {
jsonObject.put("storedValue1", fields.storedValue1);
jsonObject.put("storedValue2", fields.storedValue2);
jsonObject.put("storedValue3", fields.storedValue3);
jsonObject.put("storedValue4", fields.storedValue4);
jsonObject.put("storedValue5", fields.storedValue5);
jsonObject.put("storedValue6", fields.storedValue6);
} catch (JSONException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud) 我注意到清单文件中有两种类型的权限,"权限"和"使用权限",如下所示;
<permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Run Code Online (Sandbox Code Playgroud)
对于我将它们放在manifest.xml文件中时使用的以下4个权限?uses-permissions还是permissions?
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_WIFI_STATE
android.permission.INTERNET
android.permission.CHANGE_WIFI_MULTICAST_STATE
Run Code Online (Sandbox Code Playgroud) 我有一个活动,左侧有一个项目菜单是textViews.当用户选择其中一个textView时,它会在活动区域的其余部分放置一个listView,占用屏幕的另一个2\3.当用户触摸页面左侧菜单上的不同textView时,它将打开一个不同的相应listView项.
我正在考虑为此目的在屏幕上放置一个大的列表视图.然而另一种方式是在活动中使用常规listView,我可以在其中放置一个列表片段并在片段之间切换.
第三种选择是在其中放置一个片段并在该片段中放入一个listView.我之前从未使用过ListFragment.
考虑到不会改变方向,这将是最好的计划?活动将锁定在垂直/纵向方向.这将在平板电脑上运行,而不是在手机等小型设备上使用.
我不知道我是否需要使用加载器,因为列表不会很长,列表的内容只是文本.
使用listFragment比其他选择有什么好处吗?
此活动的三个选项:
活动ListView就可以了
活动ListFragment就可以了
具有ListView inside of theFragment`的片段的活动
如何在我的Android清单中注册我的应用程序类?我在网上看过很多教程但仍然无法正确使用.我的应用程序类被调用Monitor.java.如何在下面的清单文件代码中注册它?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.project"
android:versionCode="1"
android:versionName="1.0" >
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="@drawable/ic_launcher"
android:label="xyz"
android:screenOrientation="landscape"
android:theme="@style/AppTheme" >
<service
android:name=".AudioService"
android:icon="@drawable/ic_launcher"
android:label="audioservice" >
</service>
<activity
android:name=".MainActivity"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Editor"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="com.example.project.EDITOR" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
我将arrayList设置为12个项目,但是arrayAdapter只返回屏幕上的一个项目,为什么会这样?它应该在列表中显示12个项目.
public class MainActivity extends Activity {
ArrayList<CheckBoxInfo> cfo = new ArrayList<CheckBoxInfo>();
CheckBoxInfo cbr;
private ListAdapter MyAdapter;
ListView listview;
MyAdapter myAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cbr = new CheckBoxInfo();
cbr.checkBoxName = "dfdjklfjdkljf";
cbr.checkBoxState = true;
for(int i = 0; i <12; i++){
cfo.add(cbr);
}
Toast.makeText(MainActivity.this, "size: " + cfo.size(), Toast.LENGTH_SHORT).show();
listview = (ListView) findViewById(R.id.listView);
myAdapter = new MyAdapter(cfo, this);
listview.setAdapter(myAdapter);
}
public class MyAdapter extends ArrayAdapter<CheckBoxInfo> {
private List<CheckBoxInfo> checkBoxList;
private Context context;
public MyAdapter(List<CheckBoxInfo> infoList, …Run Code Online (Sandbox Code Playgroud) 混合来自OpenGL和Android相机的视图时图像失真,以便在使用takepicture方法时获取两者的图像.我查了一下,发现相机图片设置为640X480,openGL视图和相机预览都设置为1280x720.
所以我将相机图片大小设置为1280x720,结果非常完美.但是我无法在代码中设置大小,因为每个Android设备都会有所不同,并且每个设备都必须从支持的大小列表中选择预览大小和图片大小的设置.
考虑到这里有三个变量,活动布局的屏幕尺寸,相机预览尺寸和图片尺寸,最好的方法是什么.
是最好使用match_parent或fitXY作为FrameLayout大小,只能使用两个变量,预览大小和图片大小?
请注意预览大小和图片大小中的几个宽度和高度组合是相同的.例如1280 x 720同时存在于预览和图片中,是否总是会出现两种尺寸的匹配?
List<Size> previewSizes = mCamera.getParameters().getSupportedPreviewSizes();
List<Size> imageSizes = mCamera.getParameters().getSupportedPictureSizes();
// layout in the activity that the cameraView will placed in
int layoutWidth = frameLayout.getWidth();
int layoutHeight = frameLayout.getHeight();
Run Code Online (Sandbox Code Playgroud)
例如,在测量后的一个Android平板电脑中,这些是使用的3个变量的结果
作为测量结果的活动中布局viewGroup的大小
1280 x 736
Run Code Online (Sandbox Code Playgroud)
支持的图片尺寸
320 x 240
640 x 480
1024 x 768
1280 x 720 << best size in my example to use
1280 x 768
1280 x 920
1600 x 1200
2048 x 1536
2560 x 1440
2560 x 1536
2560 x …Run Code Online (Sandbox Code Playgroud) 我之前在几个活动中使用了方法finish()没有问题.
但是当我试图在广播接收器内部调用它时,我从编译器得到错误消息"对于AudioService类型,方法finish()未定义"
AudioService是我的Android应用程序中的Service类的名称.
如果一个服务中没有finish()方法,那么我可以调用什么来杀死这个服务?
我有一个方法,它执行SQLite数据库更新并将其放在AsyncTask中,以使其更快,更可靠.
但是,更新数据库需要两个数据.一个是Integer,另一个是此处显示的PrimaryKeySmallTank类的对象.
在AsyncTask的doInBackground方法的参数中使用params数组,我可以传入一个Integer,但是如果我有两种不同类型的数据呢?
如果整数存储在int ... params [0]中,我不能在params [1]中存储不同的类型对象,那么可以做些什么呢?
对象我想传递给AsyncTask
public class PrimaryKeySmallTank {
int contractNumber;
int customerCode;
int septicCode;
String workDate;
int workNumber;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用的AsyncTask
public class UpdateInfoAsyncTask extends AsyncTask<Integer, Void, Void>{
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
}
@Override
protected Void doInBackground(Integer... params) {
Integer mIntegerIn = params[0]; // this is what I want to do, example
PrimaryKeySmallTank mPrimaryKeySmallTank = params[1]; // different data type to pass in
Database db = new Database(InspectionInfoSelectionList.this);
db.openToWrite();
db.updateWorkClassificationByRow(mPrimaryKeySmallTank, …Run Code Online (Sandbox Code Playgroud)