fragment

unreachable statement after using .getActivity( ) in a Fragment

给你一囗甜甜゛ 提交于 2019-12-18 17:32:13
问题 I want to use .getSystemService in a Fragment. When i use .getActivity() to get the context of my activity, Android Studio tells me in the same line that this is a "unreachable statement". When there is a line above the line where i use "getActivity()", it will show that this line on top is unreachable. Why and how to fix this? public class NewNodeFragment extends Fragment { //GPS SIGNAL double pLat; double pLong; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container

原生js 浏览器滚动条滚动到底部加载数据

空扰寡人 提交于 2019-12-18 17:05:15
<!DOCTYPE html> < html lang = " en " > < head > < meta charset = " UTF-8 " > < title > Document </ title > < style > <style> * { margin : 0 ; padding : 0 ; } #app { height : 500px ; overflow-y : scroll ; } ul { list-style : none ; } li { background-color : yellowgreen ; margin-top : 2px ; } li:hover { background-color : deeppink ; } .blank { height : 1px ; } .lazy { text-align : center ; display : none ; background-color : deepskyblue ; } </ style > </ style > </ head > < body > < div id = " app " > < ul > < li > 1 </ li > < li > 2 </ li > < li > 3 </ li > < li > 4 </ li > < li > 5 </ li > <

findFragmentById() and findFragmentByTag()

会有一股神秘感。 提交于 2019-12-18 15:35:40
问题 I created a Fragment to display my recycler view. so I used the method findFragmentById() to find my xml file. The problem is each time i rotated the screen, it created one more recycler view stacks on top of one another. here is my code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListFragment savedFragment = (ListFragment) getSupportFragmentManager().findFragmentById(R.id.list_recyclerview); if

android: How to make a tab flip like android market?

二次信任 提交于 2019-12-18 13:33:34
问题 i wanna rewrite my app to fragment api, TabHost is deprecated so i've found ViewPager, but how can i make a tabbar like android market? (android market use viewpager and a bar). Superuser 3 use this bar too 回答1: Take a look at this guide: http://blog.stylingandroid.com/archives/537 回答2: The technique is called "Swipey Tabs" and is described by Kirill Grouchnikov, a google user interface engineer, in this blog post. Andreas Stütz has done a project to replicate the functionality called android

How to pass and get value from fragment and activity

旧时模样 提交于 2019-12-18 12:13:16
问题 How to pass and get value from fragment and activity? 回答1: Here is the Android Studio proposed solution (= when you create a Blank-Fragment with File -> New -> Fragment -> Fragment(Blank) and you check "include fragment factory methods"). Put this in your Fragment: class MyFragment: Fragment { ... companion object { @JvmStatic fun newInstance(isMyBoolean: Boolean) = MyFragment().apply { arguments = Bundle().apply { putBoolean("REPLACE WITH A STRING CONSTANT", isMyBoolean) } } } } .apply is a

Fragment replaced still visible on background

偶尔善良 提交于 2019-12-18 11:27:33
问题 I'm trying to replace one fragment with another one using new navigation drawer pattern. It seems to work but when I choose another option from drawer the new fragment is loaded but both fragments are visible. I'm not using static fragment layout so I don't know where is the problem. Fragments are loaded through onItemClick method implementing AdapterView.OnItemClickListener on my activity. @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Fragment

DialogFragment : NullPointerException (support library)

我的梦境 提交于 2019-12-18 11:24:52
问题 I'm using the excellent ACRA library to receive error reports from my apps. I'm receiving a lot of reports from customers concerning an NPE in DialogFragment, but Im unable to reproduce it : java.lang.NullPointerException at android.support.v4.app.DialogFragment.onActivityCreated(SourceFile:366) at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:892) at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1083) at android.support.v4.app.FragmentManagerImpl

Transfer data from Fragment Activity to Fragment

眉间皱痕 提交于 2019-12-18 09:04:45
问题 I'm working with a bluetooth service in my application which ables me to get received message from another device. In my FragmentActivity, i'm using a handler to get this message: FragmentActivity: public final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { //my code case MESSAGE_READ: byte[] readBuf = (byte[]) msg.obj; byte[] alpha = null; alpha=readBuf; if(alpha!=null){ //my code.. } } } From this Handler I would like to get a data

Mapfragment findFragmentById always null

丶灬走出姿态 提交于 2019-12-18 07:39:11
问题 I have problems to access the fragment of the map. getFragmentManager().findFragmentById(R.id.map)) returns always null. I don't know why. What's the problem? Thank you! <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/root" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/tvNombreCentro" android:layout_width="wrap_content" android:layout_height="wrap_content" android

How can I implement FragmentManager and FragmentTransaction to replace just a single fragment?

二次信任 提交于 2019-12-18 06:18:05
问题 I have an activity with 3 fragments; a header; a body; a footer (same point as in HTML). The bodyfragment contains three buttons which each should replace the middle fragment (body; itself) with another one, but I can't figure out how to work FragmentManager and FragmentTransition in here. I can't seem to find any coherency in other peoples questions on here with regards to the way others implement their fragments. It seems everyone has their own methods, or just doesn't include the full code