Android Programming Tutorials

(Romina) #1
Your Friends Seem Remote

}

};

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


status=(EditText)findViewById(R.id.status);


Button send=(Button)findViewById(R.id.send);


send.setOnClickListener(onSend);


prefs=PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(prefListener);


bindService(new Intent(IPostMonitor.class.getName()),
svcConn, Context.BIND_AUTO_CREATE);


adapter=new TimelineAdapter();
((ListView)findViewById(R.id.timeline)).setAdapter(adapter);
}


@Override
public void onDestroy() {
super.onDestroy();


try {
service.removeAccount(listener);
}
catch (Throwable t) {
Log.e("Patchy", "Exception in call to removeAccount()", t);
goBlooey(t);
}


unbindService(svcConn);
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(getApplication())
.inflate(R.menu.option, menu);


return(super.onCreateOptionsMenu(menu));
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.prefs) {
startActivity(new Intent(this, EditPreferences.class));


return(true);
}


211
Free download pdf