我正在使用PagerSlidingTabs。我有两个片段,每个片段都有一个列表视图。我添加了TabListener,因为当用户重新选择相同的选项卡时,我想进入列表视图中的第一项。这只适用于第二个片段(选项卡)。问题是第二列表视图的smoothScrollToPosition(0)方法有效,而first listview的smoothScrollToPosition(0)方法(所有方法)不起作用。第一个列表视图在屏幕上正确显示,但它的id似乎是第二个listview的id。
PagerAdapter:
public class PagerAdapter extends FragmentPager
我正在使用。因此,我需要从Fragment start Activity启动另一个Activity,在其中我有ListView,单击它我必须保存数据。
保存后,我需要返回到Fragment,其中必须显示保存的数据。这是我的Fragment
public class ArmoryFragment extends Fragment {
public ArmoryFragment(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
我有一个应用程序,我在一个片段中显示一个列表视图。但是,在创建listview时,我会得到一个空引用异常。我不知道为什么,因为在其他片段上,它工作得很好。这是我的片段和版面。
碎片:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
u
我这里有个问题。正如标题所说,我想更新一个片段中的listview,从另一个片段的edittext中添加一个值。我的主要活动是导航抽屉。我的listview片段是Fragment_hotels,另一个包含edittext的片段是FragmentAddHotel。我想在列表视图中添加一个新的酒店(包括酒店)。有人能解释一下如何做到这一点吗?代码如下:
Fragment_hotels:
public class Fragment_hotels extends Fragment {
public static boolean flag=false;
public void Add(
我是一个android应用程序的初学者,我在tab+swipe应用程序周围工作,我的主要课程是belove。请帮帮我。公共类MainScreenViewActivity扩展了FragmentActivity {
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link android.support.v4.app.FragmentPagerAdapter} d
当我通过ListViewAdpater调用MainActivity时,它工作得很好。但是如果我创建了ListViewFragment,它就不会被调用。我在ListViewFragment listViewFragment = new ListViewFragment();中添加了MainActivity。我有ListViewAdapter作为
public class ListViewAdapter extends ArrayAdapter<String> {
public ListViewAdapter(Context context, String[] sensorAr
我有一个带有两个fragments.here的活动,我在第二个片段中提供一个后退按钮,通过编程将goback转到第一个片段。
这里是我的fragment1代码:
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
V = inflater.inflate(R.layout.lm_fragement, containe
在Android中,当我创建一个带有片段的新活动时,它会在我的活动中生成一个内部静态类。问题是,因为它是一个静态的和内部的类,所以我不能用它做很多事情。
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflate
我将一个listView放在一个片段中,将一个片段放在activiti_main.xml中,并从volley库中获得一个json文件,然后解析该json文件并使用listView显示它,下面的代码运行良好。 MainActivity.java public class MainActivity extends AppCompatActivity {
public ListView listView;
private RequestQueue queue;
private ArrayList<Category> categories;
public CategoryAdapter
我无法从当前导航抽屉listview移动到另一个listview活动。从MyActivity到OS。请看public void selection()下的案例3。
MainActivity.java
public void SelectItem(int possition) {
Fragment fragment = null;
Bundle args = new Bundle();
switch (possition) {
case 0:
// Home
我想添加一些项目的简单列表视图下的Fragment活动,这是扩展Fragment,但不是ListFragment。
下面是我的代码:
public class ProductListFragment extends Fragment {
String[] ibizzproducts=
{
"Attendance",
"GPS",
"CCTV"
"Website"
我正在尝试在我的标签中创建一个ListView,它扩展了一个Fragment。当我尝试使用android.R.layout.simple_expandable_list_item_1时,我得到了一个错误。
以下是代码:
public class Tab1 extends Fragment {
ListView listView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Vi
我有一个使用ViewPager的活动,它使用FragmentStatePagerAdapter管理两个片段,
这些片段都有ListViews,每个ListView都显示数据,我可以通过滑动或点击ListView of Fragment_A从Fragment_A到Fragment_B。我还可以根据Fragment_A中选择的项更新Fragment_B的底层数据源。但当我尝试在DataAdapter of Fragment_B上使用notifyDataSetChanged()时,我得到了NullPointerException。我想根据在Fragment_B中选择的项目更新Fragment_A中的
在ListView类中有可能有自定义的Fragment吗?
这是我的片段类,其中fragment_find_people只是一个空的XML。
public class FindPeopleFragment extends Fragment {
public FindPeopleFragment(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflat
我有一个片段,它有一个带有一个项目的菜单。问题是在每一个屏幕方向上改变这个项目是加倍的。因此,在第一次屏幕更改后有2项(相同的)项,在第二次更改后有3项,等等。
public class ManageLinksFragment extends Fragment {
FragmentManager fragmentManager;
FragmentTransaction fragmentTransaction;
DBHttpLinks db;
long itemPosition;
SimpleCursorAdapter adapter;
ListView lv;
Listener m
我需要在一个片段中放置一个ListView,每当我这样做的时候,应用程序就会崩溃。
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
代码:
public class FindPeopleFragment extends Fragment {
public FindPeopleFragment(){
我有一个由5个片段组成的活动(形式)。在我的第三个片段中,我有一个listview和一个图像按钮,可以从我的手机图库中获取图像,并将其放在listview中。我对此没意见。
另外,当我滑动到我的第二和第四片段并返回到我的第三片段时,附加的图像将停留在第三段列表视图中。
但是当我滑动到第一和第五片段,回到我的第三片段,图像附加在我的第三片段列表视图上就消失了。有什么问题吗?这是我的密码:
Fragment3:
public class Fragment3 extends Fragment implements OnClickListener {
ListView lv;
Arr
我有一个从RSS.I获取和显示一些数据的ListView,我在ListView上显示,用onClickListener显示列表element.There的细节没有问题,直到here.But我的ListView类和detail类都是Fragment.When,我想从细节返回到列表片段,而不是从细节到列表片段?下面是一些代码;
public class BlogPostsFragment extends Fragment{
..。
}
public class BlogDetailFragment extends Fragment{
..。
}
这是活动中的片段交易;
private void