小编Shi*_*mar的帖子

关于SQLite中的函数db.execSQL()?

我是初学者.我学会了SQLite.我不懂函数db.execSQL(DATABASE_CREATE) ;

private static final String DATABASE_CREATE = "create table users (_id integer primary key autoincrement, "  + "name text not null);"; 
Run Code Online (Sandbox Code Playgroud)

功能如此db.execSQL().怎么说的?请帮我.谢谢,

sqlite android

1
推荐指数
1
解决办法
8276
查看次数

如何将变量从notificationmanager传递给android中的一个活动

我在通知管理器中调试一个变量,因为第一次意图成功运行但第二次当我意图新消息时,活动显示thr perivous值plz帮助我实际上是一个大问题

  1. 这是通知管理器的代码
public class GCMIntentService extends GCMBaseIntentService {

    private static final String TAG = "GCMIntentService";

    public GCMIntentService() {
        super(SENDER_ID);
    }

    @Override
    protected void onRegistered(Context context, String registrationId) {

        Log.i(TAG, "Device registered: regId = " + registrationId);

        displayMessage(context, "Your device registred with GCM");

        Log.d("NAME", MainActivity.name);

        ServerUtilities.register(context, MainActivity.name, MainActivity.email, registrationId);
    }

    @Override
    protected void onUnregistered(Context context, String registrationId) {

        Log.i(TAG, "Device unregistered");

        displayMessage(context, getString(R.string.gcm_unregistered));

        ServerUtilities.unregister(context, registrationId);
    }

    @Override
    protected void onMessage(Context context, Intent intent) {

        Log.i(TAG, "Received message");

        String message = …
Run Code Online (Sandbox Code Playgroud)

android notificationmanager

1
推荐指数
1
解决办法
6264
查看次数

ImageView In Fragment 未显示

我有一个奇怪的问题,我有一个解决方法,但想知道是否有人可以解释为什么会发生这种情况以及更优雅的解决方案?

我有一个带有一系列片段的 ViewPager。Fragment 使用自己的布局,当 ImageView 添加到布局时,ImageView 不会在运行时呈现。

如果我在 Fragment 的 onCreateView 方法中为 ImageView 显式设置 imageDrawable(即使图像与布局 xml 中引用的图像相同,则图像显示正常。

这是我的片段 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/baseRelLayout"
    android:background="@color/colorPrimary">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/flamerite_remote_6"
        android:layout_marginStart="36dp"
        android:id="@+id/remote6ButtonImage"
        android:layout_alignParentBottom="false"
        android:layout_alignStart="@+id/textView3"
        android:scaleType="fitXY"
        android:background="@color/colorPrimary"
        android:layout_alignBottom="@+id/remote9ButtonImage" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是我在 onCreateView 中重新设置可绘制图像的地方

public class WizardFragment extends Fragment {
    public static final String STEP_NUMBER = "STEP_NUMBER";

    public static  final WizardFragment newInstance(String message){
        WizardFragment f = new WizardFragment();
        Bundle bdl = new Bundle(1);
        bdl.putString(STEP_NUMBER,message);

        f.setArguments(bdl);
        return f;
    } …
Run Code Online (Sandbox Code Playgroud)

java android android-layout android-imageview android-fragments

1
推荐指数
1
解决办法
3252
查看次数

尝试在 Cast.writetoParcel 的空对象引用上调用虚拟方法“int.java.lang.Integer.intValue()”

错误图像

获取错误 FATAL EXCEPTION: main Process: com.example.wuntu.tv_bucket, PID: 3895 java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference at com. example.wuntu.tv_bucket.Models.Cast.writeToParcel(Cast.java:136) at android.os.Parcel.writeParcelable(Parcel.java:1437) at android.os.Parcel.writeValue(Parcel.java:1343) 在 android.os.Parcel.writeList(Parcel.java:759) 在 android.os.Parcel.writeValue(Parcel.java:1365) 在 android.os.Parcel.writeArrayMapInternal(Parcel.java:686) 在 android。 os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) at android.os.Bundle.writeToParcel(Bundle.java:1079) at android.os.Parcel.writeBundle(Parcel.java:711) 在 android.content.Intent.writeToParcel(Intent.java:8790) 在 android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3112) 在 android.app.Instrumentation.execStartActivity(Instrumentation.java:1541) 在 android。 app.Activity.startActivityForResult(Activity.java:4284) 在 android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50) 在 android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79) 在 android.app.Activity.startActivityForResult(Activity.java:4231) 在 android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity) .java:859) 在 android.app.Activity.startActivity(Activity.java:4568) 在 android.app.Activity.startActivity(Activity.java:4536) 在 com.example.wuntu.tv_bucket.Adapters.CastDetailAdapter$1.onClick(CastDetailAdapter.java:124) 在 android.view.View.performClick(View.java:5698) 在 android.widget.TextView.performClick(TextView. java:10908) 在 android.view.View$PerformClick.run(View.java:22557) 在 android.os.Handler.handleCallback(Handler.java:739) 在 android.os.Handler.dispatchMessage(Handler.java:95) 在 android.os.Looper.loop(Looper.java:158) 在 android.app.ActivityThread.main(ActivityThread.java:7231) …

java android arraylist android-recyclerview

1
推荐指数
1
解决办法
3万
查看次数

android中的AlertDialog按钮问题

我有一个警告对话框,应该将布尔值设置为true.因为setPositiveButton我将Dialog onclick接口设为null.当我添加onClickListenersetNegativeButtons onclick接口它给了我一个编译错误说法:该方法setNegativeButton(int, DialogInterface.OnClickListener)的类型AlertDialog.Builder是不适用的参数(String, new View.OnClickListener(){})

这是我的代码,为什么我得到编译错误,我该如何解决这个问题?谢谢

new AlertDialog.Builder(ImTracking.this)
    .setMessage(
            Html.fromHtml(getText("http://www.cellphonesolutions.net/im-following-"
                    + getResources().getString(
                            R.string.Country))))
    .setPositiveButton("OK", null)
    // The red squigly is under the .setNegativeButton
    .setNegativeButton("Don't Remind", new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            SharedPreferences prefs= getSharedPreferences("Settings",0);
            SharedPreferences.Editor editor=prefs.edit();
            editor.putBoolean("ImTrackingDontRemind",true);
            editor.commit();
        }
    }).show();
Run Code Online (Sandbox Code Playgroud)

alert android button

0
推荐指数
2
解决办法
6930
查看次数

如何从java中的hashmap获取arraylist?

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
//import java.util.Map.Entry;

public class teste{ 
    public static void main(String[] args){

    }
}
Run Code Online (Sandbox Code Playgroud)

我只是希望arraylist每个键的最终用于显示目的,即:

键的返回值:[silicone baby dolls for sale, ego ce4, venus, sample,blue]

键的返回值:[apple, banana, key, kill]

java arraylist hashmap

0
推荐指数
1
解决办法
2万
查看次数

Map-reduce JobConf - 添加FileInputFormat时出错

我创建了一个Mapper使用语法:

public class xyz extends MapReduceBase implements Mapper<LongWritable, Text, Text, Text>{
    -----
    public void map(LongWritable key, Text value,
        OutputCollector<Text, Text> output, Reporter reporter)
    --
}
Run Code Online (Sandbox Code Playgroud)

在作业中,我创建了一个Job对象:

Job job = new Job(getConf());
Run Code Online (Sandbox Code Playgroud)

对于这项工作,我无法使用以下方法添加Mapper类:

job.setMapper(xyz);
Run Code Online (Sandbox Code Playgroud)

错误信息:

The method setMapperClass(Class<? extends Mapper>) in the type Job is not applicable for the arguments (Class<InvertedIndMap1>)
Run Code Online (Sandbox Code Playgroud)

我不能使用带有extend的地图,Mapper因为我正在使用outputCollectorReportermapper.

在工作中,如果我使用JobConf而不是像以下那样的工作:

JobConf conf = new JobConf(getConf());
Run Code Online (Sandbox Code Playgroud)

然后conf.setMapper(xyz)工作.

但是无法使用以下方法设置输入路径:

FileInputFormat.addInputPaths(conf,new Path(args[0]));
Run Code Online (Sandbox Code Playgroud)

错误信息:

The method addInputPaths(Job, String) …
Run Code Online (Sandbox Code Playgroud)

hadoop mapreduce

0
推荐指数
1
解决办法
2119
查看次数

获取点击项目在 Recycleview 上的位置

我想创建一个回收视图。包含如此多产品的购物车,每当您长按产品列表项时,回收视图将显示一个上下文菜单,然后选择删除以将其从产品列表中删除。但是在获取要删除的产品的位置时遇到了一些问题。这是我的回收视图支架代码

public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener,View.OnCreateContextMenuListener {

    TextView quantity;
    TextView name;
    TextView price;
    ImageView pic;
    ImageButton increase;
    ImageButton decrease;
    int quantityInt=1;
    LongClickListener longClickListener;

    public int getQuantityInt() {
        return quantityInt;
    }

    void changeQuantityDisplay(int number)
    {
        quantity.setText(Integer.toString(number));
    }



    public void setQuantityIntPlus(int quantityInt) {
        this.quantityInt = quantityInt+1;
    }

    public void setQuantityIntMinus(int quantityInt) {
        this.quantityInt = quantityInt-1;
    }

    public MyViewHolder(View itemView) {
        super(itemView);
        View view=LayoutInflater.from(context).inflate(R.layout.activity_cart,null,false);
        name=(TextView)itemView.findViewById(R.id.listproduct_name);
        price=(TextView)itemView.findViewById(R.id.listproduct_price);
        pic=(ImageView)itemView.findViewById(R.id.listproduct_img);

        increase=(ImageButton)itemView.findViewById(R.id.increasebtn);
        decrease=(ImageButton)itemView.findViewById(R.id.decreasebtn);
        quantity=(TextView) itemView.findViewById(R.id.listproduct_quantity);
        itemView.setOnLongClickListener(this);
        itemView.setOnCreateContextMenuListener(this);


    }
    public void setLongClickListener(LongClickListener lc)
    {
        this.longClickListener=lc;

    } …
Run Code Online (Sandbox Code Playgroud)

android contextmenu android-recyclerview

0
推荐指数
1
解决办法
2179
查看次数

第一次单击时,Android Edit文本onclicklistener无效

我写了使用onClick方法来将EditText数据加载到的函数RecycleView。单击时,将EditText所有数据加载到AlertBox,如果单击一个。然后RecycleView根据它加载所有数据。第一次没有显示,但是我再次单击EditText并选择数据,AlertBox然后在RecycleView

activity_day_plan.xml

<EditText
        android:id="@+id/txtline"
        android:layout_width="156dp"
        android:layout_height="33dp"
        android:clickable="true"
        android:focusable="false"
        android:focusableInTouchMode="false"

        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="12dp"
        android:background="@drawable/input"
        android:ems="10"
        android:inputType="textPersonName"
        android:textAlignment="center"
        app:layout_constraintEnd_toStartOf="@+id/btnview"
        app:layout_constraintStart_toEndOf="@+id/txtfactoryname"
        app:layout_constraintTop_toBottomOf="@+id/txtfac" />
Run Code Online (Sandbox Code Playgroud)

主要活动

private EditText addline;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_day_plan);

    addline=(EditText)findViewById(R.id.txtline);

    addline.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getlist();
        }
    });
}

public void getlist()
{
    arrayList.clear();
    if(addfac.getText().equals(""))
    {
        Toast.makeText(DayPlanActivity.this,"Please Select Factory Code",Toast.LENGTH_SHORT).show();
    }
    else if(addline.getText().equals(""))
    {
        Toast.makeText(DayPlanActivity.this,"Please Select Line …
Run Code Online (Sandbox Code Playgroud)

android android-volley

0
推荐指数
3
解决办法
665
查看次数

onBindViewHolder() recieves ''on a null object reference''

I am trying to run my app using Adapters and I am getting this error while doing that:

Mentioning that there are 3 adapters: ReviewsAdapter, StandupWithKey and VideoAdapter.

05-07 20:16:57.707 5326-5326/com.example.sefi.authenticationproject E/ReviewsAdapter: onBindViewHolder() >> 0 05-07 20:16:57.708 5326-5326/com.example.sefi.authenticationproject E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.sefi.authenticationproject, PID: 5326 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at com.example.sefi.authenticationproject.adapter.ReviewsAdapter.onBindViewHolder(ReviewsAdapter.java:48) at com.example.sefi.authenticationproject.adapter.ReviewsAdapter.onBindViewHolder(ReviewsAdapter.java:18) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6482) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6515) at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5458) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5724) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5563) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5559) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2229) at …

java android android-studio recycler-adapter android-recyclerview

-1
推荐指数
1
解决办法
876
查看次数