我有一个RecyclerView在TabLayout中重复的片段.我在RecyclerView中遇到了视图不变的问题.我在每个标签上都有一个微调器.我想在选择微调器项目时更改数据.
我的案子:
- 在标签之间切换时 - 项目已更改
在第一个选项卡中在微调器中选择另一个值时 - 项目未更改.(但是数据在适配器类中发生了变化.首先,它在选择期间不为null然后为null.但是第一个没有空的数据没有出现,它被替换为null.使用断点找到它.
注意:在这种情况下,切换选项卡时,项目将更改为上一个选项卡中的微调器选定项目.然后它消失并在选项卡中显示当前项目.
在最后一个选项卡中在微调器中选择另一个值时 - 项目已更改.
我的视图寻呼机适配器类
public class StudentViewPagerAdapter extends FragmentStatePagerAdapter {
private final List<StudentList> mFragmentList = new ArrayList<>();
private final List<Clazz> mFragmentTitleList = new ArrayList<>();
public StudentViewPagerAdapter(FragmentManager fm) {
super(fm);
}
public void addFragment(StudentList fragment,Clazz clazz){
mFragmentList.add(fragment);
mFragmentTitleList.add(clazz);
}
@Override
public Fragment getItem(int position) {
return StudentList.newInstance(mFragmentTitleList.get(position));
}
@Override
public int getCount() {
return mFragmentList.size();
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position).getName();
}
}
Run Code Online (Sandbox Code Playgroud)
我的RecyclerView …
我有一个包含~30个字段的领域对象,在添加和删除多个对象后,似乎领域占用了相当多的空间.分配空间的大小似乎呈指数级增长:
10*(加100 +全部删除)= 4 mb数据
15*(加100 +全部删除)= 33 mb数据
20*(加100 +全部删除)= 91 mb数据
25*(加100 +全部删除)= 179 mb数据

此时,data\data\app_folder\files\default.realm中的文件本身为200 MB.
现在这个严重的问题可能是因为我没有做正确的事情.在我每次插入之前
Realm realm = Realm.getInstance(context);
realm.beginTransaction();
realm.where(RealmSubmission.class).findAll().clear();
// if i use realm.allObjects(RealmSubmission.class).clear(); the leak is even bigger, i get to 170mb Data with 20*(add 100 + remove all) even though both calls do the same by looking at their semantics.
realm.commitTransaction();
Run Code Online (Sandbox Code Playgroud)
将项添加到领域中如下所示:
for (Submission submission : submissionList){
realm.beginTransaction();
RealmSubmission realmSubmission = realm.createObject(RealmSubmission.class);
RealmObjectUtils.copySubmission(realmSubmission, submission);
realm.commitTransaction();
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我正在WebView用于加载网站.但它非常慢,并且在加载特定网站时会泄漏.我正在加载WebView以下代码.
@Override
protected void onNewIntent(Intent intent) {
if (intent.getStringExtra("url") != null) {
webView.loadurl(intent.getStringExtra("url"));
}
}
Run Code Online (Sandbox Code Playgroud)
但是在使用以下内容初始化之后,我正在调用方法webView.loadUrl(Config.URL);(Config.URL可能包含上面指定的相同url).onCreate()WebView
this.webView = (WebView) findViewById(R.id.wv);
this.webView.getSettings().setJavaScriptEnabled(true);
this.webView.getSettings().setLoadsImagesAutomatically(true);
this.webView.getSettings().setDomStorageEnabled(true);
this.webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
MyClient client = new MyClient(WebActivity.this, (ProgressBar)findViewById(R.id.progressBar));
webView.setWebViewClient(client);
Run Code Online (Sandbox Code Playgroud)
加载一个从
onCreate()工作正常(不好,它太慢).但是,这是由加载相同的URLonNewIntent()是不工作!.在我这样做之后,onNewIntent()没有使用URL加载webView.loadurl()并且当前页面变得不可移动.即.滚动条正在移动WebView但页面不滚动.我测试了相同的URLonCreate()并且它正在工作.
为此,我正在通过url
intent.putExtra("url", Config.URL+targetUrl);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Run Code Online (Sandbox Code Playgroud)
来自通知的未决意图.虽然它在一些设备上工作,即Google Nexus.但它并不适用于大多数手机.我有
android:hardwareAccelerated="true"
Run Code Online (Sandbox Code Playgroud)
我的客户
public class MyClient extends WebViewClient{
private Context context;
private Activity activity;
private Handler handler; …Run Code Online (Sandbox Code Playgroud) performance android webview android-layout android-fragments
我正在尝试创建一个将从网络加载新闻的应用程序,并将动态更新.我正在使用RecyclerView并CardView显示内容.我Jsoup用来解析网站.我不认为我的代码是必需的,因为我的问题更具理论性而非实际性.我想了解使用动态更新的过程notifyDataSetChanged().在我的主要活动中,我获取所有标题并将它们添加到列表中.但我需要等待,直到所有项目都加载开始显示它们.我真的很感激,如果有人可以发布我正在尝试做的示例代码,因为我找不到很多关于组合的信息ViewHolder,Adapter并且RecyclerView.
android android-viewholder android-cardview recycler-adapter android-recyclerview
这里我的导航抽屉在工具栏上方.我还添加了一些xml代码.请帮帮我.
这是我的activity.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_categories"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/activity_main2_drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
和我的app_bar xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.ezybzy.ezybzy.categoris">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_categoris" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
和我的内容main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.ezybzy.ezybzy.categoris"
tools:showIn="@layout/app_bar_categories"
android:background="#ffffff">
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我使用android工作室导航抽屉活动创建了导航抽屉..
在我的程序中有NetworkDispatcher.run错误我正在使用齐射库.我的程序部分是.我完成了所有方式,但没有任何工作,请帮助我做我的程序.我通过许多网络内容搜索但没有任何帮助我.我正在做的是Android中的登录验证程序.
if(!(usr.getText().toString().length()<11)&&!(pwd.getText().toString().length()<3)) {
susr = usr.getText().toString();
spwd = pwd.getText().toString();
String whois = susr.substring(0, Math.min(susr.length(), 2));
if (whois.equals("AG") || whois.equals("RT")) {
if (whois.equals("AG")) {
id = susr.substring(susr.length() - 9);
Toast.makeText(getApplicationContext(), id, Toast.LENGTH_LONG).show();
StringRequest stringRequest = new StringRequest(Request.Method.POST, agenturl,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//Toast.makeText(getApplicationContext(),response,Toast.LENGTH_LONG).show();
if(response.equals("0")){
Toast.makeText(getApplicationContext(),"Login successful",Toast.LENGTH_LONG).show();
Intent intent=new Intent(getBaseContext(),Deals.class);
startActivity(intent);
}else{
Toast.makeText(getApplicationContext(),"username or password is incorrect",Toast.LENGTH_LONG).show();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//Toast.makeText(MainActivity.this,error.toString(), Toast.LENGTH_LONG).show();
if(error instanceof NoConnectionError) {
Toast.makeText(getApplicationContext(),"No internet …Run Code Online (Sandbox Code Playgroud) 我正在开发一个带有 FCM 通知的 Android 应用程序。当应用程序在后台或前台时,我都能正确收到通知;它会发出声音并振动,单击通知会启动应用程序。一切都恰到好处。但是,当设备锁定且显示屏关闭时,设备会在收到通知时振动并发出声音。但它没有唤醒(屏幕没有打开)。只有在按下按键后,设备才会唤醒,即使在锁定屏幕中我也可以看到通知。
我有两个问题,
如何打开显示器?
如何在锁定时间屏幕中显示应用程序图标,就像锁定屏幕中的whatsapp徽标一样?
谢谢,维鲁
我想在Spark中阅读CSV。所以我在Java中使用命令。
result = sparkSession.read().csv("hdfs://master:9000/1.csv");
Run Code Online (Sandbox Code Playgroud)
它的工作原理。但是结果就像:
_c0 _c1 _c2
1 egg T
2 bob F
3 tom D
Run Code Online (Sandbox Code Playgroud)
但是文件(1.csv)没有头,结果的头没用吗?
我想要这样的结果:
ID Name Class
1 egg T
2 bob F
3 tom D
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
谢谢大家
我正在使用带有回收器视图的卡片视图。但早些时候我使用相同的代码来做事情没有任何问题。但现在我使用片段。现在我得到的卡片视图之间的距离更大了。我的回收器视图适配器
public static class DataObjectHolder extends RecyclerView.ViewHolder implements View.OnClickListener
{
TextView label;
TextView dateTime;
ImageView imageView;
ProgressBar progressBar;
public DataObjectHolder(final View itemView, final Context activity, final ArrayList<DataObject> myDataset) {
super(itemView);
label = (TextView) itemView.findViewById(R.id.textView);
//dateTime = (TextView) itemView.findViewById(R.id.thot);
imageView=(ImageView)itemView.findViewById(R.id.iproductimg);
progressBar=(ProgressBar)itemView.findViewById(R.id.progress);
Log.i(LOG_TAG, "Adding Listener");
itemView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
myClickListenerhi.onItemClick(getLayoutPosition(),v);
}
}
public MyRecyclerViewAdapter(Activity context, ArrayList<DataObject> myDataset,MyClickListener myClickListener1) {
mDataset = myDataset;
activityContext=context;
myClickListenerhi=myClickListener1;
}
@Override
public DataObjectHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.cardview, …Run Code Online (Sandbox Code Playgroud) android android-layout android-cardview android-recyclerview recyclerview-layout
我有一个Android登录的app应用程序.我在片段中初始化了facebook sdk.但是在启动登录过程时从未调用过onActivityResult.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
FacebookSdk.sdkInitialize(getContext());
AppEventsLogger.activateApp(getContext());
FacebookSdk.setApplicationId(getResources().getString(R.string.facebook_app_id));
callbackManager = CallbackManager.Factory.create();
View view=inflater.inflate(R.layout.fragment_signin, container, false);
gButton=(Button)view.findViewById(R.id.loginGmail);
fButton=(LoginButton) view.findViewById(R.id.loginFacebook);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
fButton.setReadPermissions("email");
gButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
signIn();
}
});
mGoogleApiClient = new GoogleApiClient.Builder(getContext())
.enableAutoManage(getActivity() /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
fButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Toast.makeText(getActivity(),"Success"+loginResult.getAccessToken(),Toast.LENGTH_LONG).show();
}
@Override …Run Code Online (Sandbox Code Playgroud) android ×9
adapter ×1
apache-spark ×1
callback ×1
display ×1
java ×1
performance ×1
realm ×1
toolbar ×1
webview ×1