Tag: android fragments

切换按钮以打开通知

希望你能在这里帮助我! 我想制作一个开关按钮,打开推送每日推送通知的function。 我怎么做? 切换按钮位于“设置”片段上 我的MainActivity.java: public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { @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.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); displayView(R.id.nav_home); } @Override public void […]

Android Tab Fragment(Eclipse ApI 22)中不推荐使用ActionBarActivity和ActionBar.TabListener

我正在My Tab Fragment中实现ActionBar.TabListener。 我更新了ApI 22,更新后显示ActionBar.TabListener和ActionBarActivity已弃用。 像我在我的代码中使用的那样 public class Tabview_Landing extends ActionBarActivity implements ActionBar.TabListener { } 链接我提到 – 帮我解决这个问题。

在DialogFragment中填充类片段时出错

我正在尝试使用其中的listview创建一个dialogfragment,并使用此问题中接受的答案来执行此操作 如何在DialogFragment中显示现有的ListFragment 但是当我尝试打开片段对话框并且应用程序崩溃时,我收到了一个Error inflating class fragment 下面是dialog_fragment_with_list_fragment布局 并且它不是导致它失败的androidxmlparsingactivity片段,我用其他片段尝试了它们并且它们也没有工作 下面是我的对话框片段类 public class BodyDialogue extends DialogFragment { int mNum; /** * Create a new instance of MyDialogFragment, providing “num” * as an argument. */ static BodyDialogue newInstance(int num) { BodyDialogue f = new BodyDialogue(); // Supply num input as an argument. Bundle args = new Bundle(); args.putInt(“num”, […]

谷歌分析没有反映片段

我在我的应用中使用Google Analytics。 我的应用程序中有片段。 我在基础片段上创建了一个抽象类。 并将其用于剩余片段。 任何人都可以帮我解决这个问题吗? 这就是我创建抽象类并将其扩展为片段的方法 public abstract class BaseFragment extends Fragment{..} 在这个基础片段中,我添加了谷歌分析代码,我能够在分析中跟踪它。 现在我有另一个以这种方式创建的类。 public class FirstFragmemt extends BaseFragment {..} 在这个片段中我也添加了分析代码,但它没有跟踪或反映。 有谁能说出原因是什么?

使用适配器中的不同数据更新不同ListView中的常用post

假设应用程序首先使用自定义适配器列出Fragment ( 1st )中ListView中的所有post。 并且该自定义适配器数据是ArrayList<Hashmap> 然后用户可以转到另一个片段,例如类别片段( 第2个 ),我们有另一个列表视图和不同的数据。 我们使用后台堆栈进行分段,用户可以通过单击后退按钮返回到prev片段。 问题: 在这些片段中,一些post可能很常见! 像附加图像一样,在第一张图片中,我们可以看到所有post列表中的post,当点击类别并转到类别片段时,我们可以再次看到该post。 然后,如果用户点击这个post并进入单个post活动( 第3个 ),用户可以看到像按钮,可以喜欢这篇文章( 第4个 )。 到现在为止,每件事都行! 但是当用户点击后退按钮时会发生麻烦! 第一个用户转到类别片段( 第5个 ),我们应该在列表视图上显示像按钮一样的按钮。 如果用户进一步回到所有post,我们应该喜欢该列表视图中的按钮,因为它也是! ( 第6 ) 什么是处理这个问题的最佳策略? 🙂

片段不会出现在扩展ActionBarActivity的活动中

我有一个扩展ActionBarActivity的主要活动。 在我的活动中,我创建了一个没有显示的片段。 我修改了主要活动以扩展FragmentActivity,在这种情况下片段显示出来。 当我的活动扩展ActionBarActivity时,为什么片段不显示? 我知道ActionBarActivity扩展了FragmentActivity,所以理论上ActionBarActivity应该支持片段。 编辑:我解决了。 我不会在我的活动中设置任何内容视图。 现在,我设置它,当我扩展ActionBarActivity时,它工作。 仍然很奇怪,即使我没有设置它,当我扩展FragmentActivity它工作。 这是我的主要活动代码: package com.example.yamba; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; //import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTransaction; public class StatusActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if(savedInstanceState == null) { StatusFragment fragment = new StatusFragment(); FragmentTransaction fr = getSupportFragmentManager().beginTransaction(); fr.add(android.R.id.content, fragment); fr.commit(); } } […]

由于没有找到ID错误的视图,列表片段没有出现

我正在尝试启动列表片段但它似乎只在平板电脑上工作。 当我在手机上运行我的应用程序时,应用程序崩溃了。 有谁知道如何解决这个问题? 代码如下。 错误 Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f0c0050 (com.apptacularapps.exitsexpertlondonlite:id/master_container) for fragment FragmentMainList{b76424 #1 id=0x7f0c0050} MainActivity.java public class MainActivity extends ActionBarActivity { private boolean mTwoPane; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentMainList newFragment = new FragmentMainList(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.master_container, newFragment); transaction.commit(); if (findViewById(R.id.detail_container) != null) { […]

Android / Java – GoogleMaps上的自定义视图FragmentActivity未显示

我试图在自定义视图中绘制一些Stuff进行测试,该视图被添加到GoogleMaps FragmentActivity中。 但不知何故,当我在模拟器中运行它时,似乎我的CustomView不绘图。我尝试使用新的RelativeLayout和MapLayout。 有任何想法吗 ? 我做错了什么 ? 下面是我的主要GoogleMaps FragmentActivity代码,由Android模板自动生成: public class GoogleMaps extends FragmentActivity implements OnMapReadyCallback { private GoogleMap mMap; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.google_maps); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); //RelativeLayout relativeLayout = new RelativeLayout(this); […]

单击切换开关后MapView未返回正常状态

当我将片段中的开关轻弹到OFF位置时,我正试图让我的地图视图返回到正常样式但是它不起作用。 以下是我所面临的过程中发生的情况: 片段(包含地图)和开关出现了 轻拂开关到ON位置 出现了风格的地图 轻拂开关到OFF位置 地图不会改变 我尝试使用mGoogleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); 但是当我轻拂开关时,地图仍然停留在样式化的地图视图上。 不确定出了什么问题。 必须采取哪些措施来解决这个问题? public class FragmentMap extends android.support.v4.app.Fragment implements OnMapReadyCallback { private SwitchCompat swt; public FragmentMap() { } GoogleMap mGoogleMap; MapView mMapView; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_map, container, false); mMapView = (MapView) v.findViewById(R.id.map_park); mMapView.onCreate(savedInstanceState); mMapView.getMapAsync(this); swt […]

每次更改选项卡时,选项卡片段都会获取数据

activity_profile.xml ProfileActivity.java package com.stalker.androidapp; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; import org.json.JSONException; import org.json.JSONObject; import android.app.ActionBar; import android.content.Intent; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTabHost; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.text.Html; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.Window; import android.widget.TabHost.OnTabChangeListener; import android.widget.TextView; import com.facebook.Session; import com.google.gson.Gson; import […]