findviewbyid

Can not resolve method 'findViewById(int)'

这一生的挚爱 提交于 2019-12-03 04:34:25
I'm having a trouble with findViewByid but I can't find where the problem is. Here's my FirstFragment class code: import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.ProgressBar; import java.util.ArrayList; import java.util.List; public class FirstFragment extends Fragment { public static final String

Kotlin Android View Binding: findViewById vs Butterknife vs Kotlin Android Extension

南笙酒味 提交于 2019-12-02 22:23:10
I'm trying to figure out the best way to do Android View Binding in Kotlin. It seems like there are a few of options out there: findViewById val button: Button by lazy { findViewById<Button>(R.id.button) } Butterknife https://github.com/JakeWharton/butterknife @BindView(R.id.button) lateinit var button: Button Kotlin Android Extensions https://kotlinlang.org/docs/tutorials/android-plugin.html import kotlinx.android.synthetic.main.activity_main.* I'm pretty familiar with findViewById and Butterknife in java land, but what are the pros and cons of each view binding approach in Kotlin? Does

Efficiency of findViewById

妖精的绣舞 提交于 2019-12-02 22:10:32
Probably most Android devs know that findViewById is not a cheap operation. Another thing that most of us know, is that you can boost the performance by using the smallest sub-tree of the view hierarchy to find views by their id, example: <LinearLayout android:id="@+id/some_id_0"> <LinearLayout android:id="@+id/some_id_1"> <LinearLayout android:id="@+id/some_id_2"> <TextView android:id="@+id/textview" /> </LinearLayout> </LinearLayout> </LinearLayout> In this case you probably want to search in the LinearLayout with the id == @id/textview But what is the case when the hierarchy is not

FindViewbyID with fragments

我只是一个虾纸丫 提交于 2019-12-02 07:52:16
问题 I have this problem with fragments.. I wanted to add a drawer menu in my app and than work with fragments. I have this code, and when i putted the fragments "findviewbyid" didnt works more. Someone can help me? protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_contact); final EditText nome = (EditText) findViewById(R.id.nome); final EditText citta = (EditText) findViewById(R.id.citta); final EditText numero = (EditText)

FindViewbyID with fragments

别来无恙 提交于 2019-12-02 07:00:44
I have this problem with fragments.. I wanted to add a drawer menu in my app and than work with fragments. I have this code, and when i putted the fragments "findviewbyid" didnt works more. Someone can help me? protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_contact); final EditText nome = (EditText) findViewById(R.id.nome); final EditText citta = (EditText) findViewById(R.id.citta); final EditText numero = (EditText) findViewById(R.id.numero); final EditText email = (EditText) findViewById(R.id.email); final EditText

findViewById returns null in fragment

点点圈 提交于 2019-12-01 11:49:14
问题 I have problem using the findViewByID methond in a fragment. The spinner in Spinner spinner = (Spinner) view.findViewById(R.id.tabsearchspinner_location); is always null. Please see the code below. public class FragmentTabSearch extends SherlockFragment implements OnItemSelectedListener { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View view = inflater.inflate(R.layout.fragment_tab_suggestions

NullPointerException when use findViewById() in AlertDialog.Builder

无人久伴 提交于 2019-12-01 11:24:14
This is my code @Override public void onClick(View v) { final AlertDialog.Builder adb = new AlertDialog.Builder(getApplicationContext()); adb.setView(LayoutInflater.from(getApplicationContext()).inflate(R.layout.custom, null)); adb.setPositiveButton("Add",new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { DatePicker datePicker = (DatePicker)findViewById(R.id.datePicker); java.util.Date date = null; Calendar cal = GregorianCalendar.getInstance(); cal.set(datePicker.getYear(),datePicker.getMonth(), datePicker.getDayOfMonth()); date =

NullPointerException when use findViewById() in AlertDialog.Builder

陌路散爱 提交于 2019-12-01 08:00:44
问题 This is my code @Override public void onClick(View v) { final AlertDialog.Builder adb = new AlertDialog.Builder(getApplicationContext()); adb.setView(LayoutInflater.from(getApplicationContext()).inflate(R.layout.custom, null)); adb.setPositiveButton("Add",new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { DatePicker datePicker = (DatePicker)findViewById(R.id.datePicker); java.util.Date date = null; Calendar cal = GregorianCalendar

Loading timePickerDialog from a fragment

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 09:24:48
问题 I am trying to use a custom time picker and then run the picker from a fragment. This is the code for the time picker dialog (TimePickerFragment.java): package com.ravit.android.aroundtheclock; import android.app.Dialog; import android.app.DialogFragment; import android.app.Fragment; import android.app.TimePickerDialog; import android.os.Bundle; import android.text.format.DateFormat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android

Loading timePickerDialog from a fragment

我只是一个虾纸丫 提交于 2019-11-29 15:27:47
I am trying to use a custom time picker and then run the picker from a fragment. This is the code for the time picker dialog (TimePickerFragment.java): package com.ravit.android.aroundtheclock; import android.app.Dialog; import android.app.DialogFragment; import android.app.Fragment; import android.app.TimePickerDialog; import android.os.Bundle; import android.text.format.DateFormat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TimePicker; import java.util.Calendar; /** * A simple {@link Fragment} subclass. */ public class