我正在开发一个应用程序,用户应该可以通过按其他按钮来改变按钮的外观.我使用四个按钮将高度设置为换行内容,将高度设置为填充父级,将宽度设置为换行内容,将宽度设置为填充父级.
我用Google搜索了一下,并找到了使用LayoutParams的解决方案,尽管该代码没有指定是否更改了宽度的高度.我也有错误说我的IDE无法识别"LayoutParams".做这个的最好方式是什么?
我正在尝试创建一个应用程序,其中首选项摘要根据已检查的状态更改CheckBoxPreference.
我不太确定如何查询首选项,因为好的旧版本isChecked()不起作用.
我希望能够以编程方式扩展我的操作视图。我的操作视图是搜索视图,我尝试了 mSearchView.expandActionView() 但它不起作用。如何才能做到这一点?
在今天早些时候安装Android L开发人员预览版SDK之后,我想让我的应用程序兼容Android L和旧版本,例如Jelly Bean.我的应用程序使用16的minSdkVersion但是因为我尝试了开发人员预览Android Studio似乎不尊重我的minSdkVersion.我正试图让我的应用程序在我的Galaxy Nexus(API 19)上运行,这是我得到的错误:

这是我的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.simon.holocountownapp"
android:versionCode="45"
android:versionName="4.1.1" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="L" />
...
Run Code Online (Sandbox Code Playgroud)
这是我的build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 'android-L'
buildToolsVersion '20'
defaultConfig {
minSdkVersion 16
targetSdkVersion 'L'
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile 'com.doomonafireball.betterpickers:library:1.5.2'
compile 'uk.co.androidalliance:edgeeffectoverride:1.0.1'
compile 'com.readystatesoftware.systembartint:systembartint:+'
compile "com.android.support:support-v4:+"
compile "com.android.support:support-v13:+"
}
Run Code Online (Sandbox Code Playgroud) android android-manifest android-studio android-gradle-plugin android-5.0-lollipop
我有一个片段类,我想在我的活动的"主"类中调用一个方法.片段类是静态的,因此可能是导致问题的原因,尽管我必须保持静态.我希望能够从我的静态类中做到这样的事情:
Method();
我已经尝试过:
getActivity().Method();
虽然这不起作用.我该怎么办?
我在一个应用程序上工作,我用已安装的应用程序创建一个列表,让用户选择一个.除了一件事,我一切都在工作; 按字母顺序排序.这是我正在使用的代码:
private List<App> loadInstalledApps(boolean includeSysApps) {
List<App> apps = new ArrayList<App>();
PackageManager packageManager = getPackageManager();
List<PackageInfo> packs = packageManager.getInstalledPackages(0);
for(int i=0; i < packs.size(); i++) {
PackageInfo p = packs.get(i);
App app = new App();
app.setTitle(p.applicationInfo.loadLabel(packageManager).toString());
app.setPackageName(p.packageName);
app.setVersionName(p.versionName);
app.setVersionCode(p.versionCode);
CharSequence description = p.applicationInfo.loadDescription(packageManager);
app.setDescription(description != null ? description.toString() : "");
apps.add(app);
}
return apps;
}
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏!
我正在尝试通过使用该setOnClickFillInIntent方法使我的ListView Widget中的listrows可单击,但每当我单击ListItem时都没有发生任何事情.以下是我的代码的一些关键部分:
Intent i = new Intent();
Bundle extras = new Bundle();
extras.putInt(Resource.WIDGET_PACKAGE, position);
i.putExtras(extras);
row.setOnClickFillInIntent(R.id.widget_layout_parent, i);
Run Code Online (Sandbox Code Playgroud)
这是getView()我的ViewFactory 的结尾.Resource.WIDGET_PACKAGE包含我的包名称,就像任何其他键一样.位置int来自getView()参数.R.id.widget_layout_parent是所有列表项中的父布局.
这是我的WidgetProviders的结束 onUpdate()
Intent clickIntent = new Intent(context, ItemListActivity.class);
PendingIntent clickPI = PendingIntent.getActivity(context, 0,
clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
widget.setPendingIntentTemplate(R.id.widget_layout_parent, clickPI);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds[i],
R.id.widget_list_view);
Run Code Online (Sandbox Code Playgroud)
有什么我想念的,或者你还有什么想知道的吗?
所有帮助表示赞赏!:)
android android-widget android-listview remoteview android-pendingintent
我一直试图获得在KitKat画廊中选择的图像的绝对图像路径,但它似乎没有成功.IMAGE_FILEPATH无论我做什么,我的变量总是"".这是我的代码onActivityResult()
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode != Activity.RESULT_OK) return;
if (null == data) return;
Uri originalUri = null;
if (requestCode == 1) {
//JB!!!
Uri uri = data.getData();
if (uri != null) {
try {
// User had pick an image.
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver()
.query(uri,
filePathColumn, null, null, null);
cursor.moveToFirst();
IMAGE_FILEPATH = cursor.getString(0);
cursor.close();
} catch (Exception e) {
Crouton.makeText(this, …Run Code Online (Sandbox Code Playgroud)