在notifyDataSetChanged类的方法文档中BaseAdapter指出"通知附加的观察者基础数据已经改变,反映数据集的任何视图都应该刷新自己".
假设我更改了我的字符串数组中的第3个元素(数组数据ListView),"反映数据集的任何视图应该刷新自己"是什么意思?是否会通知列表视图中的第3个视图项?
此外,如何notifyDataSetChanged()与getView()有关?
android notify android-listview android-adapter android-view
我正在使用机器人.今天我遇到了一点问题.点击按钮后,应用程序将转到下一个活动.我需要等待出现一些按钮.
View am = solo.getView(R.id.btn_login);
solo.waitForCondition(am.isShown(), 5000);
Run Code Online (Sandbox Code Playgroud)
此代码不起作用.
如果我被识别为,它也不起作用
Button am = solo.getButton(R.id.btn_login);
Run Code Online (Sandbox Code Playgroud)
帮帮我吧!
我有一个textView与OnClick方法来浏览其他活动.但是,如果我按下该文本它不会导航.但如果我使用Button代替TextView,它完美的作品.不能用OnClick方法TextView吗?
我的XML代码;
<TextView
android:onClick="webClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginLeft="17dp"
android:layout_marginTop="19dp"
android:text="Chapter 1"
android:textSize="25dp" />
Run Code Online (Sandbox Code Playgroud)
我的Java代码:
public void webClick(View v) {
Intent intent = new Intent(this, Webview.class);
startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud) 我试图通过button单击显示文本。
这是我的onClick代码:
public class Uteliv extends Activity {
public void onCrate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_uteliv);
TextView tidiTekst = (TextView) findViewById(R.id.tidiTekst);
tidiTekst.setVisibility(View.GONE);
Button tidiKnapp= (Button) findViewById(R.id.tidiKnapp);
tidiKnapp.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
tidiTekst.setVisibility(View.VISIBLE);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
怎么了?在手机上测试时,我只会得到空白页。
我一直试图获得在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) 我遇到了与其他 20 个主题几乎相同的问题,这些主题指向RuntimeException: Parcel android.os.Parcel@72a6e36: Unmarshalling unknown type code,但偏移量不同(500):
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@72a6e36: Unmarshalling unknown type code 2131365270 at offset 500
at android.os.Parcel.readValue(Parcel.java:2443)
at android.os.Parcel.readSparseArrayInternal(Parcel.java:2798)
at android.os.Parcel.readSparseArray(Parcel.java:2067)
at android.os.Parcel.readValue(Parcel.java:2421)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2717)
at android.os.BaseBundle.unparcel(BaseBundle.java:269)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:910)
at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2129)
at android.app.Activity.onRestoreInstanceState(Activity.java:1047)
at android.app.Activity.performRestoreInstanceState(Activity.java:1002)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
Run Code Online (Sandbox Code Playgroud)
尽管如此,这些主题并没有为我的案例提供解决方案。
我的问题是在将 2 个类从 Java 转换为 Kotlin 后开始出现的,这些类继承自ViewGroup并且View仅在应用程序的混淆版本中。
我的混淆器配置有一个规则:
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR; …Run Code Online (Sandbox Code Playgroud) 我试图使用android的内置控件CompoundButton,但我没有运气在xml中使用它,这是我的代码
<CompoundButton
android:id="@+id/mini_recorder_play"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_weight="1"
android:background="@drawable/play_d" />
Run Code Online (Sandbox Code Playgroud)
在充气时抛出异常.
Eclipse给了我:
error:Error:不允许字符串类型(在'layout_gravity'中,值为'center_vertical | right').
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical | right"
android:src="@android:drawable/ic_menu_camera" />
Run Code Online (Sandbox Code Playgroud)
当我切换到图形布局时,它就像我预期的那样.
android:minSdkVersion="10"
我有一个Android应用程序,我想读取和写入ArrayList<MyClass>内部存储.
写作部分工作(我相信,尚未测试它:-)):
ArrayList<MyClass> aList;
public void saveToInternalStorage() {
try {
FileOutputStream fos = ctx.openFileOutput(STORAGE_FILENAME, Context.MODE_PRIVATE);
fos.write(aList.toString().getBytes());
fos.close();
}
catch (Exception e) {
Log.e("InternalStorage", e.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud)
但我现在要做的是从存储中读取整个ArrayList并将其作为ArrayList返回,如下所示:
public ArrayList<MyClass> readFromInternalStorage() {
ArrayList<MyClass> toReturn;
FileInputStream fis;
try {
fis = ctx.openFileInput(STORAGE_FILENAME);
//read in the ArrayList
toReturn = whatever is read in...
fis.close();
} catch (FileNotFoundException e) {
Log.e("InternalStorage", e.getMessage());
} catch (IOException e) {
Log.e("InternalStorage", e.getMessage());
}
return toReturn
}
Run Code Online (Sandbox Code Playgroud)
我以前从未在Android文件中读过,所以我不知道这是否可能.但是我有一种方式可以阅读我的习惯ArrayList吗?
我希望禁用所有“不可用”项目,即当我单击它们时,下拉列表应保持不变。

我尝试设置convertView clickable false,但这没有帮助。
android ×10
java ×3
android-view ×2
textview ×2
arraylist ×1
button ×1
kotlin ×1
navigation ×1
notify ×1
parcelable ×1
return ×1
robotium ×1
storage ×1
xml ×1