Skip to main content
Formatar código
Fonte Link
ramaral
  • 44,7mil
  • 14
  • 60
  • 110

Na minha aplicação, tenho dois Fragments, um pra carregar Tweets e outro para Ler um RSS. RSS public class RssFragment extends ListFragment {

public class RssFragment extends ListFragment {
    
    private RssListAdapter adapter;
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        
            List<JSONObject> jobs = new ArrayList<JSONObject>();
            try {
                jobs = RssReader.getLatestRssFeed();
            } catch (Exception e) {
                Log.e("RSS ERROR", "Error loading RSS Feed Stream >> " + e.getMessage() + " //" + e.toString());
            }

            adapter = new RssListAdapter(getActivity(),jobs);
            setListAdapter(adapter);
                   
            return super.onCreateView(inflater, container, savedInstanceState);    
        
    }

Tweets public class Noticias extends ListFragment { final static String twitterScreenName = ""; final static String TWITTER_API_KEY = ""; final static String TWITTER_API_SECRET = ""; private static final String TAG = "Tweet";


Tweets
public class Noticias extends ListFragment {
    final static String twitterScreenName = "";
    final static String TWITTER_API_KEY = "";
    final static String TWITTER_API_SECRET = "";
    private static final String TAG = "Tweet";

    
    @Override  
      public void onListItemClick(ListView l, View v, int position, long id) {  
       //new CustomToast(getActivity(), numbers_digits[(int) id]);     
      }  
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
        .permitNetwork()
        .build());

            ArrayList<TwitterTweet> twitterTweets = null;
            TwitterAPI twitterAPI = new TwitterAPI(TWITTER_API_KEY,TWITTER_API_SECRET);
            twitterTweets = twitterAPI.getTwitterTweets("LinkOffTMMG");
            
            ArrayAdapter<TwitterTweet> adapter = new ArrayAdapter<TwitterTweet>(  
                inflater.getContext(), R.layout.twitter_tweets_list,  
                R.id.listTextView, twitterTweets);  
            
            setListAdapter(adapter);  
                   
            return super.onCreateView(inflater, container, savedInstanceState);    
        
    }
}

}

Na minha aplicação, tenho dois Fragments, um pra carregar Tweets e outro para Ler um RSS. RSS public class RssFragment extends ListFragment {

private RssListAdapter adapter;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    
        List<JSONObject> jobs = new ArrayList<JSONObject>();
        try {
            jobs = RssReader.getLatestRssFeed();
        } catch (Exception e) {
            Log.e("RSS ERROR", "Error loading RSS Feed Stream >> " + e.getMessage() + " //" + e.toString());
        }

        adapter = new RssListAdapter(getActivity(),jobs);
        setListAdapter(adapter);
               
        return super.onCreateView(inflater, container, savedInstanceState);    
    
}

Tweets public class Noticias extends ListFragment { final static String twitterScreenName = ""; final static String TWITTER_API_KEY = ""; final static String TWITTER_API_SECRET = ""; private static final String TAG = "Tweet";

@Override  
  public void onListItemClick(ListView l, View v, int position, long id) {  
   //new CustomToast(getActivity(), numbers_digits[(int) id]);     
  }  

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .permitNetwork()
    .build());

        ArrayList<TwitterTweet> twitterTweets = null;
        TwitterAPI twitterAPI = new TwitterAPI(TWITTER_API_KEY,TWITTER_API_SECRET);
        twitterTweets = twitterAPI.getTwitterTweets("LinkOffTMMG");
        
        ArrayAdapter<TwitterTweet> adapter = new ArrayAdapter<TwitterTweet>(  
            inflater.getContext(), R.layout.twitter_tweets_list,  
            R.id.listTextView, twitterTweets);  
        
        setListAdapter(adapter);  
               
        return super.onCreateView(inflater, container, savedInstanceState);    
    
}

}

Na minha aplicação, tenho dois Fragments, um pra carregar Tweets e outro para Ler um RSS. RSS

public class RssFragment extends ListFragment {
    
    private RssListAdapter adapter;
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        
            List<JSONObject> jobs = new ArrayList<JSONObject>();
            try {
                jobs = RssReader.getLatestRssFeed();
            } catch (Exception e) {
                Log.e("RSS ERROR", "Error loading RSS Feed Stream >> " + e.getMessage() + " //" + e.toString());
            }

            adapter = new RssListAdapter(getActivity(),jobs);
            setListAdapter(adapter);
                   
            return super.onCreateView(inflater, container, savedInstanceState);    
        
    }

Tweets
public class Noticias extends ListFragment {
    final static String twitterScreenName = "";
    final static String TWITTER_API_KEY = "";
    final static String TWITTER_API_SECRET = "";
    private static final String TAG = "Tweet";

    
    @Override  
      public void onListItemClick(ListView l, View v, int position, long id) {  
       //new CustomToast(getActivity(), numbers_digits[(int) id]);     
      }  
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
        .permitNetwork()
        .build());

            ArrayList<TwitterTweet> twitterTweets = null;
            TwitterAPI twitterAPI = new TwitterAPI(TWITTER_API_KEY,TWITTER_API_SECRET);
            twitterTweets = twitterAPI.getTwitterTweets("LinkOffTMMG");
            
            ArrayAdapter<TwitterTweet> adapter = new ArrayAdapter<TwitterTweet>(  
                inflater.getContext(), R.layout.twitter_tweets_list,  
                R.id.listTextView, twitterTweets);  
            
            setListAdapter(adapter);  
                   
            return super.onCreateView(inflater, container, savedInstanceState);    
        
    }
}
Fonte Link

Merge ListViews Android

Na minha aplicação, tenho dois Fragments, um pra carregar Tweets e outro para Ler um RSS. RSS public class RssFragment extends ListFragment {

private RssListAdapter adapter;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    
        List<JSONObject> jobs = new ArrayList<JSONObject>();
        try {
            jobs = RssReader.getLatestRssFeed();
        } catch (Exception e) {
            Log.e("RSS ERROR", "Error loading RSS Feed Stream >> " + e.getMessage() + " //" + e.toString());
        }

        adapter = new RssListAdapter(getActivity(),jobs);
        setListAdapter(adapter);
               
        return super.onCreateView(inflater, container, savedInstanceState);    
    
}

Tweets public class Noticias extends ListFragment { final static String twitterScreenName = ""; final static String TWITTER_API_KEY = ""; final static String TWITTER_API_SECRET = ""; private static final String TAG = "Tweet";

@Override  
  public void onListItemClick(ListView l, View v, int position, long id) {  
   //new CustomToast(getActivity(), numbers_digits[(int) id]);     
  }  

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
    .permitNetwork()
    .build());

        ArrayList<TwitterTweet> twitterTweets = null;
        TwitterAPI twitterAPI = new TwitterAPI(TWITTER_API_KEY,TWITTER_API_SECRET);
        twitterTweets = twitterAPI.getTwitterTweets("LinkOffTMMG");
        
        ArrayAdapter<TwitterTweet> adapter = new ArrayAdapter<TwitterTweet>(  
            inflater.getContext(), R.layout.twitter_tweets_list,  
            R.id.listTextView, twitterTweets);  
        
        setListAdapter(adapter);  
               
        return super.onCreateView(inflater, container, savedInstanceState);    
    
}

}

inserir a descrição da imagem aqui

Como faço para criar outro Fragment juntanto o conteudo dos outros dois ordenado pela data mais recente?