What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by MrSnowflake » Fri, 24 Apr 2009 21:01:27 GMT


Sponsored Links
 Why do so much people avoid the destoying and recreation of Activities
on orientation change. It's there to make the switch to a different
orientation easier, because it automatically loads the correct
resources. To be honest, I don't fully understand the whole recreation
of Activities neither, as it would take a lot of time to recreate the
activity and loading (and saving the instance state too) the instance
state could take a long time too. But I bet those intelligent Google
people have good reasons, that's why I follow their idea.

I don't know how to refresh your UI. If you mean by refreshing:
loading the appropriate resources to get the correct layout for the
current orientation, then you need to destroy and recreate the
Activity. That's why the system does this by default!

You should save all current state specific information in
onSaveInstancestate() (or what is it called, I forgot, it's a couple
of weeks ago I did some Androiding :) ) and reload it in
onRestoreInstancestate(). And well, all this stuff is in the docs so
you can take a look there :).



--~--~---------~--~----~------------~-------~--~----~



What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by Wang He » Mon, 27 Apr 2009 10:56:20 GMT


 Is here anybody knows the right way?
Still waiting ...

BRs
He



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by Wang He » Mon, 27 Apr 2009 16:26:10 GMT


 1. I don't want to  recreate the activity when switching at Land &
Port, many runtime data I don't want to save and reload;
2. So I use onConfigurationChanged() facility, but I have UI for Land
& Port, What I do now is:
    public void onConfigurationChanged(Configuration newConfig) {
           setContentView() again as onCreate();
          run findViewById()s as handlers will lost after
setContentView();
          setListeners for UI widgets as they will lost also;
  }

3. Is the way right I did in 2?

BRs
He





--~--~---------~--~----~------------~-------~--~----~



What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by MrSnowflake » Mon, 27 Apr 2009 19:52:06 GMT


 You don't have to load and save that stuff, you can put references to
your runtime data in a custom class and return that in
Activity.onRetainNonConfigurationInstance()  (http://
developer.android.com/reference/android/app/
Activity.html#onRetainNonConfigurationInstance()) and get it in
Activity.getLastNonConfigurationInstance().






--~--~---------~--~----~------------~-------~--~----~



What is the correct way to refresh UI when I use android:configChanges="keyboardHidden|orientation"

by quakeboy » Tue, 28 Apr 2009 17:17:00 GMT


 You might want to take a look at setRequestedOrientation if u want
to ..



--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Get the value from database

Hi guys,

                    i have some problem to getting url from database
so any one help me......
i have listview in my rssReader i want to when i click the list view
then go to the database get the url and display the rss feeds......


Here is my code......

protected void onListItemClick(ListView l, View v, int position, long
id) {
        super.onListItemClick(l, v, position, id);
        Intent i = new Intent(this, RSSReader.class);

        i.putExtra(NewsDbAdapter.KEY_ROWID, id);
        startActivityForResult(i, ACTIVITY_VIEW);

    }

This is RSSReader.java


ackage com.android.worldnews;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.w3c.dom.Text;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class RSSReader extends Activity implements OnItemClickListener
{


  @SuppressWarnings("unused")
private static final int ACTIVITY_DESCRIPTION = 0;


  private static final int position = 0;
 // private static final String MY_RSS = "NewsDbAdapter.KEY_ROWID";
  private static final String MY_RSS="http://www.ibnlive.com/xml/rss/
sports.xml";//this is my default value i want to get my databse.....
please help me
  private String FeedURL;
  private RSSFeed feed = null;
  private EditText mFeedURLText;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);



    feed = getFeed(MY_RSS);
    UpdateDisplay();



  }



@SuppressWarnings("unchecked")
/*public void onItemClick(AdapterView parent, View v, int position,
long id) {


        Intent i = new Intent(this,ShowDescription.class);
    RSSItem item = feed.getItem(position);

    i.putExtra("title", item.getTitle());
    i.putExtra("description", item.getDescription());
    i.putExtra("link", item.getLink());
    i.putExtra("pubdate", item.getPubdate());

    startActivityForResult(i, ACTIVITY_DESCRIPTION);
  }
 */
    private void UpdateDisplay() {
    TextView feedDescription=(TextView) findViewById
(R.id.feeddescription);
    TextView feedTitle = (TextView) findViewById(R.id.feedtitle);
    TextView feedPubdate = (TextView) findViewById(R.id.feedpubdate);
    //ExpandableListView itemList=(ExpandableListView)findViewById
(R.id.itemlist);
    ListView itemList = (ListView) findViewById(R.id.itemlist);

    if (feed == null) {
      feedTitle.setText("No RSS Feed Available");
      return;
    }

    feedTitle.setText(feed.getTitle());
    feedPubdate.setText(feed.getPubdate());
    feedDescription.setText(feed.getDescription());

    ArrayAdapter<RSSItem> adapter = new ArrayAdapter<RSSItem>(this,
        android.R.layout.simple_expandable_list_item_1,
feed.getAllItems());

    itemList.setAdapter(adapter);
    itemList.setSelection(0);
    itemList.setOnItemClickListener(this);


  }

  private RSSFeed getFeed(String urlToRssFeed) {
    try {
      URL url = new URL(urlToRssFeed);

      SAXParserFactory factory = SAXParserFactory.newInstance();
      SAXParser parser = factory.newSAXParser();

      XMLReader xmlReader = parser.getXMLReader();
      RSSHandler rssHandler = new RSSHandler();
      xmlReader.setContentHandler(rssHandler);

      InputSource is = new InputSource(url.openStream());
      xmlReader.parse(is);

      return rssHandler.getFeed();
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }



@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long
arg3) {
        // TODO Auto-generated method stub

}




please help me anyone i want this




--~--~---------~--~----~------------~-------~--~----~

2. WebView failing on G1

My application is an Android application which launches a web 2.0
application for the Android Market using WebView.  The web 2.0
application works perfectly on my G1 when run with the G1 browser.
When I run my Android application, it loads the initial screen and
then freezes.  Tapping or Menu do nothing.  The app is fairly complex
with a lot of Javascript.

The Objective C WebView version runs perfectly on the iPhone.

I am using Windows XPSP3, eclipse 3.4.1 &, R1 of the Android SDK.

Is the WebKit different for the iPhone?  If so, will the Android
version become compatible with the iPhone version and when?

--~--~---------~--~----~------------~-------~--~----~

3. What are the MediaPlayer Class upcoming fixes?

4. Issue reagrding check out from SVN

5. Where, exactly, are Context data files?

6. How to see the documents under Android /frameworks/base/docs?

7. how can I select text from a webpage using webview?