我无法在FragmentPagerAdapter中重用片段.使用destroyItem()方法,它正在删除片段,但仍然没有再次调用getItem().只有2-3个图像所以我使用FragmentPagerAdapter而不是FragmentStatePagerAdapter ..
public class ExamplePagerAdapter extends FragmentPagerAdapter {
ArrayList < String > urls;
int size = 0;
public ExamplePagerAdapter(FragmentManager fm, ArrayList < String > res) {
super(fm);
urls = res;
size = urls.size();
}
@Override
public int getCount() {
if (urls == null) {
return 0;
} else {
return size;
}
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
FragmentManager manager = ((Fragment) object).getFragmentManager();
FragmentTransaction trans = manager.beginTransaction();
trans.remove((Fragment) object);
trans.commit();
}
@Override
public Fragment getItem(int …Run Code Online (Sandbox Code Playgroud) 我计划在不同的设备大小上为textview使用不同的字体大小,以使字母清晰可辨.我已经决定不为不同的设备使用不同的布局,并构建了一个适合所有设备的通用布局.现在唯一的问题是文本大小.
问题:
我想就如何根据设备的大小(物理尺寸)改变字体大小提出技术建议.
如何根据宽高比导出字体大小.
使用这种方法有什么缺陷吗?
Xml用于文本视图
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical">
<TextView
android:id="@+id/tvValue4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="I planned to use different font size for the textview on different device size so as to make the letters legible. I have already decided not to use different layouts for different devices and built a common layout to fit in all the devices. Now the only problem is on the text size."
android:textColor="#000000"
android:textSize="15sp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
提前致谢
我想制作一个多行编辑文本,但问题是每当我输入新的行编辑文本高度增加.如何修复它的高度.我的代码是
<EditText
android:id="@+id/editAdditionalInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editPhoneCutomerDetails"
android:layout_alignParentBottom="true"
android:layout_marginBottom="60dp"
android:layout_below="@+id/editPhoneCutomerDetails"
android:layout_marginTop="10dp"
android:background="@drawable/message_additional_box1x"
android:ems="10"
android:padding="10dp"
android:gravity="top">
<requestFocus />
</EditText>
Run Code Online (Sandbox Code Playgroud) 我创建了一个可以在其内部存储中导入文件的应用程序.为了打开与外部应用程序文件(例如PF观众或照片),我试图按照这些指南:官方指南,TOPIC1,标题2,topic3和topic4但没有成功.
这是我的代码:
在我的清单中
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.myapp.chatcher"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
Run Code Online (Sandbox Code Playgroud)
我的包价值: package="com.myapp.catcher"
我的file_paths.xml
<paths
xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="projection" path="." />
</paths>
Run Code Online (Sandbox Code Playgroud)
我的代码
String fileName = path.substring(path.lastIndexOf("/") + 1);
String shelf = path.substring(path.lastIndexOf("PRIVATE") + 8, path.lastIndexOf("/"));
File filePath = new File(mContext.getFilesDir(), "PRIVATE".concat("/").concat(shelf).concat("/"));
File newFile = new File(filePath, fileName);
Uri contentUri = FileProvider.getUriForFile(mContext, "com.myapp.chatcher", newFile);
Intent myIntent = new Intent();
myIntent.setAction(Intent.ACTION_VIEW);
myIntent.setData(contentUri);
myIntent.setType(mimeType);
myIntent.setFlags(FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION);
mContext.startActivity(myIntent);
Run Code Online (Sandbox Code Playgroud)
我创建了这样的层次结构:
PRIVATE -> …Run Code Online (Sandbox Code Playgroud) 介绍
我有一个Book的活动,其中包含一个类型为"page"的arraylist,并处理我决定使用FragmentStatePagerAdapter的所有页面,其中我的一个片段包含一个页面.
我为寻呼机中的每个片段和父活动之间的通信创建了一个接口.我在这个接口中需要的方法是更新页面中显示的页面,所以我为父活动创建了工具,用于从片段接收数据的接口并将它们存储在页面中以保存在arraylist中.
每个片段都有一个EditText,用户可以在其中编写,我设置addTextChangedListener来捕获用户停止写入的时刻.当用户停止在EditText中写入时,在onTextChanged()中,我调用activity father中实现的函数.
这是我的活动代码
public class BookEditorActivity implements BookEditorFragment.EditorFrToEditorActInterface {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.book_editor_activity);
Bundle extras = getIntent().getExtras();
b = (Book) extras.get("book");
setBookViewPager(b);
}
private void setBookViewPager(Book b) {
mBookViewPager = (ViewPager) findViewById(R.id.book_editor_pager);
mBookViewPagerAdapter = new BookViewPagerAdapter(getSupportFragmentManager(), b);
mBookViewPager.setAdapter(mBookViewPagerAdapter);
}
@Override
public void saveBookPageTextContent(String textContent) {
int current = mBookViewPager.getCurrentItem();
if (b.getPages().get(current) instanceof BookPageText) {
((BookPageText) b.getPages().get(current)).setContentPageText(textContent);
}
}
@Override
public void newBookPageText() {
int current = mBookViewPager.getCurrentItem();
BookPageText bookPageText = new BookPageText();
bookPageText.setContentPageText(""); …Run Code Online (Sandbox Code Playgroud) android android-fragments android-viewpager fragmentstatepageradapter
我正在使用自定义波纹 drawable
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_shortAnimTime"
android:color="@android:color/white">
<item android:id="@android:id/mask">
<shape android:shape="rectangle" >
<solid android:color="@android:color/white" />
</shape>
</item>
</ripple>
Run Code Online (Sandbox Code Playgroud)
但它崩溃了API 19上的应用程序
android.content.res.Resources$NotFoundException: File res / drawable /
ripple_effect_square2.xml from drawable resource ID #0x7f02017d
at android.content.res.Resources.loadDrawable(Resources.java:2101)
at android.content.res.Resources.getDrawable(Resources.java:700)
at android.view.View.setBackgroundResource(View.java:15303)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line # 2: invalid drawable tag ripple
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java: 933)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java: 877)
at android.content.res.Resources.loadDrawable(Resources.java: 2097)
at android.content.res.Resources.getDrawable(Resources.java: 700)
at android.view.View.setBackgroundResource(View.java: 15303)
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能防止崩溃?
我正在寻找将 MySql 数据库迁移到 Firebase 的新 Cloud Firestore 的最佳方法。步骤是什么?我首先尝试将关系数据库中的表和关系转换为文档逻辑。我阅读了Cloud Firestore REST API,因为我在使用 REST 而不是套接字方面有更多经验,但我不确定这是否是重点。从这个示例开始创建一个脚本并在 nodeJS 上运行它是个好主意吗?有没有人已经做过这件事?谢谢
在此示例中,单击日期可以对其进行编辑,但如果您使用选项“stopEditingWhenGridLosesFocus”,则日期选择器将不再工作。有可能解决这个问题吗?
<AgGridReact
stopEditingWhenGridLosesFocus // without this line works fine
columnDefs={this.state.columnDefs}
components={this.state.components}
onGridReady={this.onGridReady.bind(this)}
rowData={this.state.rowData}
/>
Run Code Online (Sandbox Code Playgroud) 当我\xe2\x80\x99m在哨兵问题描述页面时,我可以看到哨兵服务收集的一些信息,并且我\xe2\x80\x99d希望避免收集它们以避免隐私问题。
\n我\xe2\x80\x99d 不希望看到的信息是:app.device和用户 ID,如您在此处看到的:
\n\n是否可以?我\xe2\x80\x99m 担心新的苹果隐私限制。我不知道我是否理解正确,但有必要使用弹出窗口或类似的方式向用户解释该应用程序正在使用第三方软件来收集有关“应用程序崩溃”和“应用程序崩溃”的数据表现”。让用户可以选择不收集这些数据会给开发人员带来很多麻烦。\n我搜索了所有项目设置和文档,但我只找到了隐藏某些标签/数据的方法,但重点不是隐藏信息,但根本不收集它们。
\n谢谢
\n我想允许使用只输入5行,我试过这个
<EditText
android:layout_below="@+id/tv_signup_descriptionError"
android:id="@+id/et_signup_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:hint="@string/et_hint_enterDescription"
android:singleLine="false"
android:lines="5"
android:gravity="top"
android:scrollHorizontally="false"
android:inputType="textMultiLine"
android:maxLines="5"/>
Run Code Online (Sandbox Code Playgroud)
但是我仍然可以Enter在第五行之后按下
该RecyclerView在activity_main有三个复选框,并在底部activity_main是一个按钮,点击它时,保存checkbox状态(真或假)和它的适配器的位置hashmap.位置是关键,状态是值.两者都转换为String.我想将它保存到sharedpreferences.我发现原始数据类型可以保存到shared preferences.有没有办法保存hashmap到它.
RecyclerAdapter.java:
public class RecyclerHolder extends RecyclerView.ViewHolder {
AnimCheckBox checkBox;
checkBox = (AnimCheckBox) itemView.findViewById(R.id.checkBox);
checkBox.setChecked(false);
public RecyclerHolder(final View itemView) {
super(itemView);
checkBox.setOnCheckedChangeListener(new AnimCheckBox.OnCheckedChangeListener() {
@Override
public void onChange(boolean checked) {
checkboxclick = true;
if (checkBox.isChecked()) {
boolean check = true;
clicked_position = getAdapterPosition();
String position = Integer.toString(clicked_position);
String check_status = Boolean.toString(check);
hashMap.put(position, check_status);
} else {
String …Run Code Online (Sandbox Code Playgroud)