I'm curious about which way is more accurate in the way traceview provides profiling such as sampling-based or trace-based. The documentation only talks about the overhead caused due to the two and in that context sampling-based is a better choice as it causes less over head (relative to the sampling frequency).

So the main question is that which one is more accurate or suitable for comparing various implementation of a function or two different functions?

My concern with sampling based method is that it may not catch a function which has execution time small that the inter-sample interval.

i am trying to find the uid from firebase, lets i have 3 users in my database, and i want to find the 3rd user uid, here is code what i done but , it is not working for me

photo of firebase dashbord

 final FirebaseDatabase database = FirebaseDatabase.getInstance();
    myRef = database.getReference();
   DatabaseReference newRef = myRef.push();

                i++;
                Student s = new Student("ameerhamza",i,"hamza");
                newRef.child(newRef.getKey()).setValue(s);
                final Query queryRef = myRef.orderByChild("emailId").equalTo("ameerhamzaaaa");

             queryRef.addListenerForSingleValueEvent(new ValueEventListener() {
                 @Override
                 public void onDataChange(DataSnapshot dataSnapshot) {
                     Log.d("Firebase UID ",dataSnapshot.getKey());//it always null 
                     Student s = dataSnapshot.getValue(Student.class);



                 }

                 @Override
                 public void onCancelled(DatabaseError databaseError) {

                 }
             });

Is there a way to create the image below where the thumb text is updated based on the progress using the seek bar listener. Also having the image at the bottom to be attached to the seekbar so that it is in the same position on all devices.

I have tried creating a TextDrawable and set the thumb to it but when scrolled to the top or bottom it gets slightly cropped.

Also have played with creating a custom vertical seek bar and rotating the seekbar, both have problems with regards to the seek bar requiring the dimensions (width/height) being the same for it to look and work correctly.

Final output

I'm making an Android app for my final project and everything was fine and working until I added one more activity. Then, when I try to login the Sign in button does not start the main activity and does not crash either, basically nothing happens. After stopping my app, I get this:

W/InputDispatcher: channel 'ca84fab checkapp.com.br.checkapp/checkapp.com.br.activities.InicioActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
E/InputDispatcher: channel 'ca84fab checkapp.com.br.checkapp/checkapp.com.br.activities.InicioActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
W/InputDispatcher: Attempted to unregister already unregistered input channel 'ca84fab checkapp.com.br.checkapp/checkapp.com.br.activities.InicioActivity (server)'

How can I fix that? I tried to delete the new activity but it does not help, but it happened after I added it.

Thanks!

I get "Unfortunately the app has stopped" whenever I return from add_activity. I don't really know why.

It has to get data from an intent then put it in a database

I took out the imports because the text is too big

Main Activity

  package com.thehuntestshadow.laken;

        //Imports


        public class MainActivity extends AppCompatActivity{
            MyDBHandler 

dbHandler =new MyDBHandler(this,null,null,1);
        MyDBManager dbManager = new MyDBManager(this,null,null,1);
        ExpandableListAdapter listAdapter;
        ExpandableListView expListView;
        List<String> listDataHeader;
        HashMap<String, List<String>> listDataChild;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        expListView = (ExpandableListView) findViewById(R.id.lvExp) ;

        prepareListData();

        listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);

    // setting list adapter
    expListView.setAdapter(listAdapter);



    String[] days = {"Monday", "Tuesday", "Wednesday", "Thursday","Friday", "Saturday", "Sunday"};


   /* ListAdapter alex_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, days);
    ListView main_list = (ListView) findViewById(R.id.main_list);
    main_list.setAdapter(alex_adapter);

    main_list.setOnItemClickListener(

            new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    String day = String.valueOf(parent.getItemAtPosition(position));
                    Toast.makeText(MainActivity.this, day, Toast.LENGTH_SHORT).show();
                }
            }


    );*/
    expListView.setOnGroupClickListener(new OnGroupClickListener() {

        @Override
        public boolean onGroupClick(ExpandableListView parent, View v,
                                    int groupPosition, long id) {
            // Toast.makeText(getApplicationContext(),
            // "Group Clicked " + listDataHeader.get(groupPosition),
            // Toast.LENGTH_SHORT).show();
            return false;
        }
    });

    // Listview Group expanded listener
    expListView.setOnGroupExpandListener(new OnGroupExpandListener() {

        @Override
        public void onGroupExpand(int groupPosition) {
            Toast.makeText(getApplicationContext(),
                    listDataHeader.get(groupPosition) + " Expanded",
                    Toast.LENGTH_SHORT).show();
        }
    });

    // Listview Group collasped listener
    expListView.setOnGroupCollapseListener(new OnGroupCollapseListener() {

        @Override
        public void onGroupCollapse(int groupPosition) {
            Toast.makeText(getApplicationContext(),
                    listDataHeader.get(groupPosition) + " Collapsed",
                    Toast.LENGTH_SHORT).show();

        }
    });

    // Listview on child click listener
    expListView.setOnChildClickListener(new OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView parent, View v,
                                    int groupPosition, int childPosition, long id) {
            // TODO Auto-generated method stub
            Toast.makeText(
                    getApplicationContext(),
                    listDataHeader.get(groupPosition)
                            + " : "
                            + listDataChild.get(
                            listDataHeader.get(groupPosition)).get(
                            childPosition), Toast.LENGTH_SHORT)
                    .show();
            return false;
        }
    });






}
private void prepareListData() {
    listDataHeader = new ArrayList<String>();
    listDataChild = new HashMap<String, List<String>>();

    // Adding child data
    listDataHeader.add("Top 250");
    listDataHeader.add("Now Showing");
    listDataHeader.add("Coming Soon..");

    // Adding child data
    List<String> top250 = new ArrayList<String>();
    top250.add("The Shawshank Redemption");
    top250.add("The Godfather");
    top250.add("The Godfather: Part II");
    top250.add("Pulp Fiction");
    top250.add("The Good, the Bad and the Ugly");
    top250.add("The Dark Knight");
    top250.add("12 Angry Men");

    List<String> nowShowing = new ArrayList<String>();
    nowShowing.add("The Conjuring");
    nowShowing.add("Despicable Me 2");
    nowShowing.add("Turbo");
    nowShowing.add("Grown Ups 2");
    nowShowing.add("Red 2");
    nowShowing.add("The Wolverine");

    List<String> comingSoon = new ArrayList<String>();
    comingSoon.add("2 Guns");
    comingSoon.add("The Smurfs 2");
    comingSoon.add("The Spectacular Now");
    comingSoon.add("The Canyons");
    comingSoon.add("Europa Report");

    listDataChild.put(listDataHeader.get(0), top250); // Header, Child data
    listDataChild.put(listDataHeader.get(1), nowShowing);
    listDataChild.put(listDataHeader.get(2), comingSoon);
}



public void OnClick(View view) {
    Intent i = new Intent(this, Add_Activity.class);
    startActivityForResult(i, 1);


}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent meow) {

    if (requestCode == 1) {
        if(resultCode == Activity.RESULT_OK){


            Data data = new Data ();
            data.set_description(meow.getStringExtra("description"));
            data.set_activityname(meow.getStringExtra("name"));
            dbHandler.addProducts(data);
            Days days1 = new Days();
            int [] array = new int[7];
            array = meow.getIntArrayExtra("array");
            days1.set_monday(array[0]);
            days1.set_tuesday(array[1]);
            days1.set_wednesday(array[2]);
            days1.set_thursday(array[3]);
            days1.set_friday(array[4]);
            days1.set_saturday(array[5]);
            days1.set_sunday(array[6]);
            dbManager.addActivity(days1);



        }
        if (resultCode == Activity.RESULT_CANCELED) {
            //Write your code if there's no result
        }
    }
}//onActivityResult








### Activity_Add ###

        package com.thehuntestshadow.laken;

//Imports

public class Add_Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_);
}
//OnClick



public void OnClick (View view)
{
    int [] array = new int[7];
    for(int i = 0;i<7;++i)
        array[i]=0;
    CheckBox a = (CheckBox) findViewById(R.id.MondayCheck);

    if(a.isChecked())array[0]=1;
     a = (CheckBox) findViewById(R.id.TuesdayCheck);
    if(a.isChecked())array[1]=1;
     a = (CheckBox) findViewById(R.id.WednesdayCheck);
    if(a.isChecked())array[2]=1;
    a = (CheckBox) findViewById(R.id.ThursdayCheck);
    if(a.isChecked())array[3]=1;
    a = (CheckBox) findViewById(R.id.FridayCheck);
    if(a.isChecked())array[4]=1;
    a = (CheckBox) findViewById(R.id.SaturdayCheck);
    if(a.isChecked())array[5]=1;
    a = (CheckBox) findViewById(R.id.SundayCheck);
    if(a.isChecked())array[6]=1;

    Intent i = new Intent(this,MainActivity.class);

    EditText g =  (EditText) findViewById(R.id.data_enter);

    i.putExtra("array",array);
    i.putExtra("description",g.getText().toString());
    g = (EditText) findViewById(R.id.title);
    i.putExtra("name",g.getText().toString());
  setResult(Activity.RESULT_OK,i);
    finish();



  }

//activity_add

Layout XML

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_add_"
    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"
    tools:context="com.thehuntestshadow.laken.Add_Activity">

    <TextView
        android:text="Welcome bitch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="129dp"
        android:layout_marginStart="129dp"
        android:layout_marginTop="18dp"
        android:id="@+id/welcome_text"
        android:focusable="true"
        android:focusableInTouchMode="true"

    />

    <CheckBox
        android:text="Wednesday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/WednesdayCheck"
        android:layout_below="@+id/TuesdayCheck"
        android:layout_alignLeft="@+id/TuesdayCheck"
        android:layout_alignStart="@+id/TuesdayCheck"
        android:layout_marginTop="10dp" />

    <CheckBox
        android:text="Tuesday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/TuesdayCheck"
        android:layout_below="@+id/MondayCheck"
        android:layout_alignLeft="@+id/MondayCheck"
        android:layout_alignStart="@+id/MondayCheck"
        android:layout_marginTop="12dp" />

    <CheckBox
        android:text="Thursday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="14dp"
        android:id="@+id/ThursdayCheck"
        android:layout_below="@+id/WednesdayCheck"
        android:layout_alignLeft="@+id/WednesdayCheck"
        android:layout_alignStart="@+id/WednesdayCheck" />

    <CheckBox
        android:text="Friday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/FridayCheck"
        android:layout_below="@+id/ThursdayCheck"
        android:layout_alignLeft="@+id/ThursdayCheck"
        android:layout_alignStart="@+id/ThursdayCheck" />

    <CheckBox
        android:text="Saturday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/FridayCheck"
        android:layout_alignRight="@+id/ThursdayCheck"
        android:layout_alignEnd="@+id/ThursdayCheck"
        android:id="@+id/SaturdayCheck" />

    <Button
        android:text="Done"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/change_button"
        android:onClick="OnClick"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@+id/FridayCheck"
        android:layout_toEndOf="@+id/FridayCheck" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine"
        android:ems="10"
        android:id="@+id/data_enter"
        android:layout_above="@+id/change_button"
        android:layout_alignLeft="@+id/SaturdayCheck"
        android:layout_alignStart="@+id/SaturdayCheck"
        android:layout_marginBottom="11dp"
        android:hint="Blah" />

    <CheckBox
        android:text="Monday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/MondayCheck"
        android:layout_marginLeft="29dp"
        android:layout_marginStart="29dp"
        android:layout_marginTop="52dp"
        android:layout_below="@+id/welcome_text"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <CheckBox
        android:text="Sunday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/SaturdayCheck"
        android:layout_alignLeft="@+id/SaturdayCheck"
        android:layout_alignStart="@+id/SaturdayCheck"
        android:layout_marginTop="11dp"
        android:id="@+id/SundayCheck" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:text="Name"
        android:ems="10"
        android:layout_below="@+id/welcome_text"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:id="@+id/title" />
</RelativeLayout>

Layout XML

<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="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#f4f4f4"
    android:weightSum="1"
    android:id="@+id/Rel_l">
<LinearLayout 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="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#f4f4f4"
    android:weightSum="1">

    <ExpandableListView
        android:id="@+id/lvExp"
        android:layout_height="match_parent"
        android:layout_width="match_parent"/>



</LinearLayout>

    <android.support.design.widget.FloatingActionButton
        android:layout_width="54dp"
        android:layout_height="wrap_content"
        android:clickable="true"
        app:fabSize="mini"
        app:srcCompat="@drawable/ic_add_black_48dp"
        android:id="@+id/myFAB"
        android:layout_gravity="bottom|center_vertical"
        android:layout_weight="5.13"
        android:layout_alignParentBottom="true"

        android:onClick="OnClick" />

</RelativeLayout>

Log

http://txt.do/d5cbn

Here is the link

// I think its from the database

Data

    package com.thehuntestshadow.laken;

  //Import

    public class MyDBHandler extends SQLiteOpenHelper{

    private static final int DATABASE_VERSION =1;
    private static final String DATABASE_NAME ="product.db";
    public static final String TABLE_PRODUCTS = "products";
    public static final String COLUMN_ID ="_id";
    public static final String COLUMN_ACITVITYNAME = "activityname";
    public static final String COLUMN_DESCRIPTION = "description";

    public MyDBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    public MyDBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
        super(context,DATABASE_NAME, factory, DATABASE_VERSION, errorHandler);
    }




    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        db.execSQL("DROP TABLE IF EXISTS" + TABLE_PRODUCTS);

    }





    @Override
    public void onCreate(SQLiteDatabase db) {

        String query = "CREATE TABLE" + TABLE_PRODUCTS + "(" +
                COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT" +COLUMN_ACITVITYNAME + " TEXT " + COLUMN_DESCRIPTION + " TEXT " + ");";
        db.execSQL(query);
    }



    public void addProducts (Data product)
    {
        ContentValues values = new ContentValues();
        values.put(COLUMN_ACITVITYNAME, product.get_activityname());
        SQLiteDatabase db= getWritableDatabase();
        db.insert(TABLE_PRODUCTS,null,values);
        db.close();
    }


    public void deleteProduct (String productName)
    {
        SQLiteDatabase db = getWritableDatabase();
        db.execSQL(" DELETE FROM " + TABLE_PRODUCTS + " WHERE " + COLUMN_ACITVITYNAME + "=\"" + productName + "\";" );
    }

}

MyDBHandler

package com.thehuntestshadow.laken;

 //Imports

    public class MyDBHandler extends SQLiteOpenHelper{

    private static final int DATABASE_VERSION =1;
    private static final String DATABASE_NAME ="product.db";
    public static final String TABLE_PRODUCTS = "products";
    public static final String COLUMN_ID ="_id";
    public static final String COLUMN_ACITVITYNAME = "activityname";
    public static final String COLUMN_DESCRIPTION = "description";

    public MyDBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    public MyDBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
        super(context,DATABASE_NAME, factory, DATABASE_VERSION, errorHandler);
    }




    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        db.execSQL("DROP TABLE IF EXISTS" + TABLE_PRODUCTS);

    }





    @Override
    public void onCreate(SQLiteDatabase db) {

        String query = "CREATE TABLE" + TABLE_PRODUCTS + "(" +
                COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT" +COLUMN_ACITVITYNAME + " TEXT " + COLUMN_DESCRIPTION + " TEXT " + ");";
        db.execSQL(query);
    }



    public void addProducts (Data product)
    {
        ContentValues values = new ContentValues();
        values.put(COLUMN_ACITVITYNAME, product.get_activityname());
        SQLiteDatabase db= getWritableDatabase();
        db.insert(TABLE_PRODUCTS,null,values);
        db.close();
    }


    public void deleteProduct (String productName)
    {
        SQLiteDatabase db = getWritableDatabase();
        db.execSQL(" DELETE FROM " + TABLE_PRODUCTS + " WHERE " + COLUMN_ACITVITYNAME + "=\"" + productName + "\";" );
    }

}

Days

package com.thehuntestshadow.laken;

/**
 * Created by User1 on 10/15/2016.
 */

public class Days {
    private int _id;
    private int _monday;
    private int _tuesday;
    private int _wednesday;
    private int _thursday;
    private int _friday;
    private int _saturday;
    private int _sunday;

    public  Days()
    {


    }

    public Days(int _tuesday, int _sunday, int _saturday, int _friday, int _thursday, int _wednesday, int _monday, int _id) {
        this._tuesday = _tuesday;
        this._sunday = _sunday;
        this._saturday = _saturday;
        this._friday = _friday;
        this._thursday = _thursday;
        this._wednesday = _wednesday;
        this._monday = _monday;
        this._id = _id;
    }

    public void set_monday(int _monday) {
        this._monday = _monday;
    }

    public void set_tuesday(int _tuesday) {
        this._tuesday = _tuesday;
    }

    public void set_saturday(int _saturday) {
        this._saturday = _saturday;
    }

    public void set_wednesday(int _wednesday) {
        this._wednesday = _wednesday;
    }

    public void set_friday(int _friday) {
        this._friday = _friday;
    }

    public void set_thursday(int _thursday) {
        this._thursday = _thursday;
    }

    public void set_sunday(int _sunday) {
        this._sunday = _sunday;
    }

    public int get_monday() {
        return _monday;
    }

    public int get_tuesday() {
        return _tuesday;
    }

    public int get_wednesday() {
        return _wednesday;
    }

    public int get_friday() {
        return _friday;
    }

    public int get_thursday() {
        return _thursday;
    }

    public int get_sunday() {
        return _sunday;
    }

    public int get_saturday() {
        return _saturday;
    }

    public Days(int answer) {
        this._monday = answer;
    }

    public void set_id(int _id) {
        this._id = _id;
    }

    public void set_answer(int _answer) {
        this._monday = _answer;
    }

    public int get_id() {
        return _id;
    }

    public int get_answer() {
        return _monday;
    }
}

MyDBManager

package com.thehuntestshadow.laken;

import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.Cursor;
import android.content.Context;
import android.content.ContentValues;

public class MyDBManager extends SQLiteOpenHelper {

    private static final int DATABASE_VERSION_DAYS =1;
    private static final String DATABASE_NAME_DAYS ="days.db";
    public static final String TABLE_DAYS = "days";
    public static final String COLUMN_ID_DAYS ="_id";
    public static final String COLUMN_SATURDAY = "_saturday";
    public static final String COLUMN_MONDAY =  "_monday";
    public static final String COLUMN_TUESDAY = "_tuesday";
    public static final String COLUMN_WEDNESDAY = "_wednesday";
    public static final String COLUMN_THURSDAY = "_thursday";
    public static final String COLUMN_FRIDAY = "_friday";
    public static final String COLUMN_SUNDAY = "_sunday";


    public MyDBManager(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, DATABASE_NAME_DAYS, factory, DATABASE_VERSION_DAYS);
    }



    @Override
    public void onCreate(SQLiteDatabase db) {

        String query = "CREATE TABLE" + TABLE_DAYS + "(" +
                COLUMN_ID_DAYS + " INTEGER PRIMARY KEY AUTOINCREMENT" +COLUMN_MONDAY + " INTEGER " + COLUMN_TUESDAY + " INTEGER " + COLUMN_WEDNESDAY + " INTEGER " + COLUMN_THURSDAY + " INTEGER " +
                COLUMN_FRIDAY + " INTEGER " + COLUMN_SATURDAY + " INTEGER " + COLUMN_SUNDAY + " INTEGER " + ");";
        db.execSQL(query);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS" + TABLE_DAYS);

    }

    public void addActivity (Days product)
    {
        ContentValues values = new ContentValues();
        values.put(COLUMN_MONDAY,product.get_monday());
        values.put(COLUMN_TUESDAY,product.get_tuesday());
        values.put(COLUMN_WEDNESDAY,product.get_wednesday());
        values.put(COLUMN_THURSDAY,product.get_thursday());
        values.put(COLUMN_FRIDAY,product.get_friday());
        values.put(COLUMN_SATURDAY,product.get_saturday());
        values.put(COLUMN_SUNDAY,product.get_sunday());
        SQLiteDatabase db= getWritableDatabase();
        db.insert(TABLE_DAYS,null,values);
        db.close();
    }


}

MainFest

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".RestaurantDetail"></activity>
</application>

Main Activity

public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener,
                                                           android.view.View.OnClickListener {
private boolean viewIsAtHome; // 每次 press back 都回到 about(初始頁面)
Button buttonEditAddYes,buttonEditUorD;
TextView restaurantID;

// ----------- 每當按下Button按下,則跑到OnClick()執行對應Function -----------

@override
public void onClick(View view) {
    if (view== findViewById(R.id.buttonEditAddYes)){ // 確定新增 (Edit_Add內)

        Intent intent = new Intent(MainActivity.this,RestaurantDetail.class);
        intent.putExtra("restaurantID",0);
        startActivity(intent);

    }

    else if (view== findViewById(R.id.buttonEditAddNo) ){ // 清除 (Edit_Add內)

    }


    else if (view== findViewById(R.id.buttonEditUorD)) { // 當按下 (Edit內)

        RestaurantRepo repo = new RestaurantRepo(this);

        ArrayList<HashMap<String, String>> restaurantList =  repo.getRestaurantList();
        if(restaurantList.size()!=0) {
            ListView lv = (ListView) findViewById(R.id.list);
            lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
                    restaurantID = (TextView) view.findViewById(R.id.restaurantID);
                    String idRestaurant = restaurantID.getText().toString();
                    Intent objIndent = new Intent(getApplicationContext(),RestaurantDetail.class);
                    objIndent.putExtra("restaurantID", Integer.parseInt(idRestaurant));
                    startActivity(objIndent);
                }
            });
            ListAdapter adapter = new SimpleAdapter( MainActivity.this,restaurantList, R.layout.edit_fragment_fix_view,
                    new String[] { "id","name","type","price","phone","addr"},
                    new int[] {R.id.restaurantID, R.id.restaurantNAME,R.id.restaurantTYPE,
                            R.id.restaurantPRICE,R.id.restaurantPHONE,R.id.restaurantADDR});
            lv.setAdapter(adapter);
        }else{
            Toast.makeText(this,"No restaurant!",Toast.LENGTH_SHORT).show();
        }

    }

}
// ------------------------------------------------------------------------

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setItemIconTintList(null); // 顯示Icon圖案,不會讓他黑黑的
    navigationView.setNavigationItemSelectedListener(this);
    displayView(R.id.menu_about); // 一開始看About

    // -------------------- 新增 / 修改 / 刪除  --------------------

    buttonEditAddYes = (Button)findViewById(R.id.buttonEditAddYes);  
    buttonEditAddYes.setOnClickListener(this);// !!!!!!!!!!!!!!!!!!!!!! Here got error

    buttonEditUorD = (Button)findViewById(R.id.buttonEditUorD);     
    buttonEditUorD.setOnClickListener(this); // !!!!!!!!!!!!!!!!!!!!!! because of ↑ , so this may cause error too

    // ------------------------------------------------------------
}

RestaurantDetail

public class RestaurantDetail extends Activity implements android.view.View.OnClickListener {


Button buttonEditUpdate ,  buttonEditDelete;

EditText editTextNAME;
EditText editTextTYPE;
EditText editTextPRICE;
EditText editTextPHONE;
EditText editTextADDR;
//EditText editTextSCORE;

private int _RestaurantID = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_fragment_fix_uord);
    // buttonEditUorD按下時 跳到 edit_fragment_fix_uord去修改

    buttonEditUpdate = (Button) findViewById(R.id.buttonEditUpdate);
    buttonEditDelete = (Button) findViewById(R.id.buttonEditUpdate);

    editTextNAME = (EditText) findViewById(R.id.editTextUpdateName);
    editTextTYPE = (EditText) findViewById(R.id.editTextUpdateType);
    editTextPRICE = (EditText) findViewById(R.id.editTextUpdatePrice);
    editTextPHONE = (EditText) findViewById(R.id.editTextUpdatePhone);
    editTextADDR = (EditText) findViewById(R.id.editTextUpdateAddr);
    //editTextSCORE = (EditText) findViewById(R.id.ratingBarUpdate);


    buttonEditUpdate.setOnClickListener(this);
    buttonEditDelete.setOnClickListener(this);


    _RestaurantID =0;
    Intent intent = getIntent();
    _RestaurantID =intent.getIntExtra("restaurantID", 0);
    RestaurantRepo repo = new RestaurantRepo(this);
    Restaurant restaurant = new Restaurant();
    restaurant = repo.getRestaurantById(_RestaurantID);

    editTextNAME.setText(restaurant.name);
    editTextTYPE.setText(String.valueOf(restaurant.type));
    editTextPRICE.setText(String.valueOf(restaurant.price));
    editTextPHONE.setText(restaurant.phone);
    editTextADDR.setText(restaurant.addr);
    //editTextSCORE.setText(String.valueOf(restaurant.score));
}

@Override
public void onClick(View view) {
    // TODO Auto-generated method stub
    if (view == findViewById(R.id.buttonEditUpdate)){
        RestaurantRepo repo = new RestaurantRepo(this);
        Restaurant restaurant = new Restaurant();

        restaurant.restautant_ID =_RestaurantID;
        restaurant.name = editTextNAME.getText().toString();
        restaurant.type =  Integer.parseInt(editTextTYPE.getText().toString()) ;
        restaurant.price = Integer.parseInt(editTextPRICE.getText().toString()) ;
        restaurant.phone = editTextPHONE.getText().toString();
        restaurant.addr = editTextADDR.getText().toString();
        //restaurant.score = Integer.parseInt(editTextSCORE.getText().toString());

        if (_RestaurantID==0){
            _RestaurantID = repo.insert(restaurant);

            Toast.makeText(this,"New Restaurant Insert",Toast.LENGTH_SHORT).show();
            finish();
        }

        else{

            repo.update(restaurant);
            Toast.makeText(this,"Restaurant Record updated",Toast.LENGTH_SHORT).show();
            finish();
        }
    }

    else if (view== findViewById(R.id.buttonEditDelete)){
        RestaurantRepo repo = new RestaurantRepo(this);
        repo.delete(_RestaurantID);
        Toast.makeText(this, "Restaurant Record Deleted", Toast.LENGTH_SHORT);
        finish();
    }

}

}

Hi everyone, I am new to Android Studio . I decided to make a button to insert information to my SQLite database.

When i click on the button( buttonEditAddYes ), it passes parameters to another activity( RestaurantDetail ).

buttonEditAddYes.setOnClickListener(this); <<---- Error happen in this line

I think maybe I am missing to extends ListActivity in my MainActivity (?)

But I already extend AppCompatActivity .. OMG please help me thank you guys so much !

Process: com.example.user.foody, PID: 4577 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.foody/com.example.user.foody.RestaurantDetail}: java.lang.ClassCastException: android.widget.TableRow cannot be cast to android.widget.EditText at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) at android.app.ActivityThread.access$900(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5942) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) Caused by: java.lang.ClassCastException: android.widget.TableRow cannot be cast to android.widget.EditText at com.example.user.foody.RestaurantDetail.onCreate(RestaurantDetail.java:39) at android.app.Activity.performCreate(Activity.java:6288) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)  at android.app.ActivityThread.access$900(ActivityThread.java:177)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5942)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)

I understand that there are two types of inspections in Android Studio, those which are inherited from IntelliJ and those which are inherited from lint (see: Android lint on command-line missing issue groups (versus options available in Android Studio)).

I also understand that when you right a custom lint rule and add it to an Android project it is automatically converted into an inspection.

Based on these two assertions I am lead to believe there is a mechanism which converts lint rules to IntelliJ inspections. In this article it states "Using the Structural Search Inspection is the only way to create custom inspections through the IntelliJ IDEA interface. Alternatively, you can develop an external plugin to implement a custom inspection.". So from this I gather that there must be a "lint plugin" which takes the lint rules and turns them into inspections.

So my question is, is this the case? If so, can someone point me to the source code of this plugin?

I try to create a list of cards with info on it. So, i have main activity, wich start card actovity:

  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.add_new_user) {            
        Intent intent = new Intent(this, AddNewUserActivity.class);
        startActivity(intent);        
    } else if (id == R.id.view_rating) {
        Intent intent=new Intent(this,ViewAllPlayersActivity.class);
        startActivity(intent);
     }         
    return true;
}

ViewAllPlayersActivity:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final RecyclerView    _recyclerView = (RecyclerView) findViewById(R.id.activity_view_all_players);
// use a linear layout manager
final LinearLayoutManager    _layoutManager = new LinearLayoutManager(this);
    _recyclerView.setLayoutManager(_layoutManager); //null here

    setContentView(R.layout.activity_view_all_players);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    _recyclerView.setHasFixedSize(true);
    PlayerManager playerManager=new PlayerManager();
    // specify an adapter (see also next example)
    _adapter = new ShowAllPlayersAdapter(playerManager.getAllPlayers());
    _recyclerView.setAdapter(_adapter);       
        }
    });
}

layout:

<?xml version="1.0" encoding="utf-8"?>

<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_view_all_players" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    app:srcCompat="@android:drawable/ic_dialog_email" />

And content_view_all_players layout file:

 <?xml version="1.0" encoding="utf-8"?>

<!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_gravity="center"
    android:layout_width="200dp"
    android:layout_height="200dp"
    card_view:cardCornerRadius="4dp">
    <TextView
        android:id="@+id/player_name"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</android.support.v7.widget.CardView>

The problem is in that line:

 _recyclerView.setLayoutManager(_layoutManager); //null here

Why i get null? Can you help me?

I'm using tvjs & tvml to run my app on AppleTV. But I'm experiencing an issue with TvOS 10.0.1, the app stop the audio in background. But I added "UIBackgroundModes" as "audio" in the info.plist. Any ideas to solve the problem ?

I am developing a simple Xamarin Forms app that would be running on iOs and Android. My app has more or less 5000 words that I will be displaying on the screen randomly every 5 seconds. Which between the two would be best to use performance-wise?

Im new to ios dev and I want to have spacing between certain cells like the official settings app has. Is there a way to do it in 1 TableView or do I have to insert more of them? If I have more TableViews the screen is not fully scrollable and maybe not all of them are able to show.

I have many cells in table. How i get current row second and third cell input values,multiply these values and put it into third cell. These values must be get and multiply by key up.

<table>
      <tr>
          <td><a href="#"></td>
           <td><input type="text" value=""></input></td>
          <td><input type="number" value=""></input></td>
          <td><input type="number" value=""></input></td>
          <td><input type="number" value=""></input><span></span></td>
      </tr>
      <tr>
          <td><a href="#"></td>
          <td><input type="text" value=""></input></td>
          <td><input type="number" value=""></input></td>
          <td><input type="number" value=""></input></td>
          <td><input type="number" value=""></input><span></span></td>
      </tr>
</table> 

How do I create a numpad using the main.xml and write the numbers in a text box?Like a keyboard that when you press 1,1 will be type in the text box.

I am trying to find offline tool for diagramming for use PHP OOP projects that does not require much dragging around and positioning elements manually.

I spend too much time free dragging of objects and links (arrows) between objects, at the end they look out of place anyway and i drag them again and again before i get tired of it and just tell myself screw this.

Need a tool where you simply add box for class then another box for child class and it positions them automatically and creates link automatically, with least hand dragging as possible, i like it to be aligned automatically. Or button to auto position elements according to parent-child relationships.

Ideally should support UML.

I've been doing research on CI (continuous integration) and I can't find any info on the changes CI would introduce to ticket sizing.

CI states developers should merge to the mainline every day (or even multiple times a day), but if that is the case doesn't that mean when sizing tickets those tickets would have to be broken down into even smaller tickets that would only take a day or less to complete or am I just integrating fragments of code that pass unit test but are not the complete ticket?

example: say I have a ticket that my team would normally size a 3 which would equate to 5 working days, under CI rules would a developer be integrating the commits (that pass unit testing) he or she did for that day into the mainline (keeping in mind the ticket is still not complete) or is that ticket to large for CI and in turn the ticket would need to be broken down into smaller tickets where each one of those new smaller tickets would need to be done in a day or less?

The most important feature of an imperative program is the state and their modifications.

ReactJs encourages as much functional style of programming (e.g. using purity, higher-order functions). I want to know if using immutable state in ReactJs this characteristic still as an imperative feature or could be considered as functional "style of state"?

Theoretically, what is the difference between the React state and state in pure imperative programs?

We're developing a web application that is now growing to quite a few pages, all dealing with complex data and rather complex interactions between pages.

For instance, the login flow encompasses the following different possible requests to our controllers:

  • Login -> Forgot Password -> Send email [POST only] -> Password reset token -> New password submit -> Back to Login
  • Login -> Create New User -> Signup [POST only] -> Send activation email
  • Login -> Process new invite requests -> Main page

...and a couple of more different variations, all including sending emails, asking for verification/activation tokens; and that's not even starting to touch upon the multiple wizard-like pages for connecting to external applications and so on.

Is there a good way of documenting all of these different URLs, their parameters, and the ways that these interact with each other? For complex web applications, having a way to refer to all these different requests must be a rather good resource... And especially in terms of security, being able to visually inspect the flow of requests and spotting potential glitches. (Hey, why is this page a GET? It should be a POST with CSRF protection!)

I just don't feel like a Word document is enough... UML? xmldoc?

Not that it matters at all, but it's written in C#.

I've done a lot of research on this so I'll tell you what I sort of think it does and then hopefully someone can tell me what it actually does.

I'm trying to understand the MVVM pattern by learning from a tutorial (link). I'll put all the code here in case anybody wants to drop it into Xcode.

My view model is called GreetingViewModel which adopts a protocol and contains this line of code I don't understand:

protocol GreetingViewModelProtocol: class {      
  var greeting: String? { get }
  var greetingDidChange: ((GreetingViewModelProtocol) -> ())? { get set }
  init(person: Person)
  func showGreeting()
}

class GreetingViewModel : GreetingViewModelProtocol {
  let person: Person
  var greeting: String? {
    didSet {
      self.greetingDidChange?(self)
    }
  }

  // what does line do???
  var greetingDidChange: ((GreetingViewModelProtocol) -> ())?

  required init(person: Person) {
    self.person = person
  }

  @objc func showGreeting() {
    self.greeting = "Hello" + " " + self.person.firstName + " " + self.person.lastName
  }
}

In the view controller (below), when self.viewModel = viewModel executes, this runs the code in the property observer of var viewModel. That then assigns the function (GreetingViewModelProtocol) -> () to var greetingDidChange.

class GreetingViewController : UIViewController {
  let showGreetingButton = UIButton()
  @IBOutlet weak var greetingLabel: UILabel!

  var viewModel: GreetingViewModelProtocol! {
    didSet {
      self.viewModel.greetingDidChange = { [unowned self] viewModel in
        self.greetingLabel.text = viewModel.greeting
      }
    }
  }

  required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
  }

  override func viewDidLoad() {
    super.viewDidLoad()

    let model = Person(firstName: "David", lastName: "Blaine")

    let viewModel = GreetingViewModel(person: model)

    self.viewModel = viewModel

    showGreetingButton.backgroundColor = UIColor.red
    showGreetingButton.tintColor = UIColor.black
    showGreetingButton.setTitle("Show Greeting", for: .normal)
    showGreetingButton.addTarget(self.viewModel, action: #selector(GreetingViewModel.showGreeting), for: .touchUpInside)

    showGreetingButton.translatesAutoresizingMaskIntoConstraints = false    
    view.addSubview(showGreetingButton)
    let buttonTop = NSLayoutConstraint(item: showGreetingButton, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.greaterThanOrEqual, toItem: view, attribute: NSLayoutAttribute.topMargin, multiplier: 1.0, constant: 20)
    let buttonLeading = NSLayoutConstraint(item: showGreetingButton, attribute: NSLayoutAttribute.leading, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.leadingMargin, multiplier: 1.0, constant: 0.0)
    showGreetingButton.contentEdgeInsets = UIEdgeInsetsMake(2, 2, 2, 2)
    NSLayoutConstraint.activate([buttonTop, buttonLeading])
  }
}

At this point, I believe this just means greetingDidChange holds a function that accepts any class object that adopts the GreetingViewModelProtocol protocol and returns nothing. The UI finishes loading and looks like this:

enter image description here

When I click on the Show Greeting button, GreetingViewModel.showGreeting() is called then the property observer on var greeting is executed (self.greetingDidChange?(self)) sending GreetingViewModel to this mysterious line of code I don't understand.

That causes this property observer to execute:

  var viewModel: GreetingViewModelProtocol! {
    didSet {
      self.viewModel.greetingDidChange = { [unowned self] viewModel in
        self.greetingLabel.text = viewModel.greeting
      }
    }
  }

Then the rest of the code executes and the message is displayed:

enter image description here

I think that because the viewModel is GreetingViewModel, that closure in the var viewModel property observer is setting self.greetingLabel.text = GreetingViewModel.greeting. There seems to be some kind of relationship between my mystery line of code var greetingDidChange: ((GreetingViewModelProtocol) -> ())? and the code in viewModel.didSet, but it beats me how it works.

Am I even close and would someone be kind enough to explain to me what's going on here?

Also, my simple model is:

struct Person {
  let firstName: String
  let lastName: String
}

enter image description here

I am getting started with react native, in my app i want to add above controls on the navigation bar. Any idea how can i do it?

I am using navigationIos control, this route is initialRoute. I don't see any way of adding segmentedcontrol or toolbar icons in the navigation bar.

This is ios only app.

I know to retrieve the names of contacts that's code below. But what should I change in this code to also have the numbers of phone associated with the contact list?

  var uri = ContactsContract.Contacts.ContentUri;

            string[] projection = { ContactsContract.Contacts.InterfaceConsts.Id,
   ContactsContract.Contacts.InterfaceConsts.DisplayName };

            var cursor = ManagedQuery(uri, projection, null, null, null);

            var contactList = new List<string>();

            if (cursor.MoveToFirst())
            {
                do
                {
                    String phoneNumber = cursor.GetString(cursor.GetColumnIndex(ContactsContract.CommonDataKinds.Phone.Number));

                contactList.Add(cursor.GetString(
                        cursor.GetColumnIndex(projection[1])));
            } while (cursor.MoveToNext());
        }                

I occured this issue when running ionic run android cmd enter image description here

Any help ?