I have created a Tab Activity showing a number of tabs defined in an xml string array. Each tab has the same listview as content which I update with different data.
I can see my tabs and the content updated each time I click on a tab, but the first tab (when activity is created) is never displayed.
I can see in my logs that onTabChanged is called when onCreate is executing, but the result is not displayed. If I change selected tab and go back to the first, I can see it.
This is my code :
public class MyActivity extends TabActivity {
protected final void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LOGGER.debug("onCreate.start");
setContentView(R.layout.mylayout);
listview = (ListView) findViewById(R.id.listview);
adapter = new MyAdapter(getApplicationContext(), new ArrayList<Station>());
listview.setAdapter(adapter);
final Resources res = getResources();
final TabHost tabHost = getTabHost();
tabHost.setOnTabChangedListener(new OnTabChangeListener(
(MyApplication) getApplicationContext()));
TabHost.TabSpec spec;
final String[] tabsString = res.getStringArray(R.array.tabs);
for (int i = 0; i < tabsString.length; i++) {
final String[] tab = tabsString[i].split("\\|");
spec = tabHost.newTabSpec(tab[0]).setIndicator(tab[1]);
spec.setContent(R.id.tabcontent);
tabHost.addTab(spec);
tabHost.getTabWidget().getChildAt(i).getLayoutParams().width = TAB_WIDTH;
}
LOGGER.debug("onCreate.end");
}
public void onTabChanged(final String tabId) {
LOGGER.debug("onTabChanged.start");
refreshTask = new AsyncTask<Void, Void, List<Station>>() {
#Override
protected void onPreExecute() {
/* Show progress bar and hide list view. */
findViewById(R.id.loading).setVisibility(View.VISIBLE);
findViewById(R.id.listview).setVisibility(View.GONE);
};
#Override
protected List<Station> doInBackground(final Void... params) {
return getStations(0, 0, tabId);
}
#Override
protected void onPostExecute(final List<Station> result) {
if (result != null) {
adapter.setStations(result);
} else {
adapter.clear();
}
adapter.notifyDataSetChanged();
/* Hide progress bar and show list view. */
findViewById(R.id.loading).setVisibility(View.GONE);
findViewById(R.id.listview).setVisibility(View.VISIBLE);
}
};
refreshTask.execute();
LOGGER.debug("onTabChanged.end");
}
}
And this is the log I can see in LogCat console :
MyActivity onCreate.start
MyActivity onTabChanged.start
MyActivity onTabChanged.end
MyActivity onCreate.end
Do you have an idea ?
Thanks
Following Line of code is causing problem
adapter = new MyAdapter(getApplicationContext(), new ArrayList());
you are passing arralist with size 0 hence no data displayed.
But when tab changes at then in your listener you passing arralist which contains some data and hence you are able to see data when you come back.
Enjoy..
Try setting the first tab as active at the end of your onCreate after you create all the tabs:
tabHost.setCurrentTab(0);
Related
I am developing android application which having multiple tabs.
Now in launcher activity tabs display perfectly and can navigate through the tabs.
but if i call activity(which i wanted to show as Tab) on Button Clicked then tabs seems disappear.
please refer the given code and let me know if i am doing something wrong.
This is Main TabActivity
public class MyTabActivity extends TabActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab);
TabHost tabHost=getTabHost();
TabSpec deshTab=tabHost.newTabSpec("Deshboard");
deshTab.setIndicator("Deshboard");
Intent DeshboardIntent=new Intent(this,DeshboardActivity.class);
deshTab.setContent(DeshboardIntent);
tabHost.addTab(deshTab);
TabSpec clientTab=tabHost.newTabSpec("client");
clientTab.setIndicator("client");
Intent intent=new Intent(this,ClientActivity.class);
clientTab.setContent(intent);
tabHost.addTab(clientTab);
}
}
Now i wanted to start client activity like
void onButtonClick(View view)
{
int id = view.getId();
switch(id)
{
case R.id.client_btn:
Intent clientIntent = new Intent(DeshboardActivity.this,ClientActivity.class);
startActivity(clientIntent);
break;
}
}
but when i click this button it starts new activity but NOT in tab.
what should i do to display this activity in tab on button click also.?
Below code is ClientActivity which i wanted to display as TAB.
public class ClientActivity extends Activity
{
private DatabaseHandler dbHandler;
private ListView clientListView ;
private BaseAdapter listAdapter;
TabHost tabHost;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.clientactivity);
dbHandler = new DatabaseHandler(this);
final List<Client> clientList = dbHandler.getAllclient();
clientListView = (ListView)findViewById(R.id.client_list);
listAdapter = new ClientListAdapter(this, clientList);
clientListView.setAdapter(listAdapter);
clientListView.setOnItemClickListener(new OnItemClickListener()
{
#Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id)
{
Client client = clientList.get(position);
Toast.makeText(getApplicationContext(), client.getFirstName(), Toast.LENGTH_LONG).show();
Intent clientInfoIntent = new Intent(getApplicationContext(), ClientInfoActivity.class);
clientInfoIntent.putExtra("client",client);
startActivity(clientInfoIntent);
//finish();
}
});
}
}
That's because your ClientActivity is launched on top of your TabActivity. That way your tabbar is not shown anymore.
I suggest you use fragments for your ClientActivity.
A tutorial how to use fragments:
http://developer.android.com/guide/components/fragments.html
In my application i'm using two tabs one tab app contacts and other one is all contacts ,in application opening a one tab to other one it tack 10sce ,in that time how to add the same type of message like loading screen etc ,
plz tell me how to do that in my android app?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabview);
final TabHost tabHost = getTabHost();
TextView txtTab = new TextView(this);
txtTab.setText("Mobell Contacts");
txtTab.setPadding(8, 9, 8, 9);
txtTab.setTextColor(Color.WHITE);
txtTab.setTextSize(14);
//txtTab.setTypeface(localTypeface1);
txtTab.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
TabHost.TabSpec spec;
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("tab1").setIndicator(txtTab).setContent(new Intent(this, ContactList.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
tabHost.addTab(spec);
TextView txtTab1 = new TextView(this);
txtTab1.setText("All Contacts");
txtTab1.setPadding(8, 9, 8, 9);
txtTab1.setTextColor(Color.WHITE);
txtTab1.setTextSize(14);
//txtTab.setTypeface(localTypeface1);
txtTab1.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
TabHost.TabSpec spec1;
// Initialize a TabSpec for each tab and add it to the TabHost
spec1 = tabHost.newTabSpec("Tab2").setIndicator(txtTab1).setContent(new Intent(this, TabAct2.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
tabHost.addTab(spec1);
tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#101010"));
tabHost.getTabWidget().getChildAt(1).setBackgroundColor(Color.parseColor("#848284"));
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
#Override
public void onTabChanged(String tabId) {
for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
{
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#848284"));
}
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#181418"));
}
});
}
}
see this code plz tell how to add the progressDialog when tab change one to other...
You can do something like this for showing progress -
public class MainActivity extends Activity {
Button b;
ProgressBar pb1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b = (Button)findViewById(R.id.button1);
pb1 = (ProgressBar)findViewById(R.id.progressBar1);
}
public void click(View v){
new Thread("thread1"){
public void run(){
try{
for(int i=0; i<10; i++)
{
Thread.sleep(4000);
pb1.setProgress(i*10);
}
}
catch(InterruptedException e){
e.printStackTrace();
}
};
}.start();
}
}
In case you want to show a message, use Spinner.
Show progressbar on center of screen using visibility on/off
Since you are using TabActivity (and you haven't posted your work around yet), so, I am guessing you have used
TabActivity
Activity (for both tabs)
Now, when you switch from one tab to another you are actually calling Activity. So, just create an AsyncTask in the Activity which takes time to load. For instance,
class ContactLoadAsync extends AsyncTask<Void, Void, Void> {
ProgressDialog pd;
#Override
protected void onPreExecute()
pd = ProgressDialog.show(YourActivity.this, "title", "loading", true, false);
}
#Override
protected Void doInBackground(Void... params) {
// call your contact loading functions here
return null;
}
#Override
protected void onPostExecute(Void result) {
pd.dismiss();
}
}
And, call this AsyncTask in onCreate() of your Activity.
new ContactLoadAsync().execute();
I am using a ListFragment for displaying a list from a database in my activity. I have included a search function. Unfortunately the "old" ListFragments seem to remain in the background and the ListFragments containing the result of the query are displayed on top of it. How can I avoid, that the old ListFragments are displayed?
My FragmentActivity:
private Button buttonSearch;
private TextView searchString;
public static String search = null;
static IShoppinglist shoppinglistManager;
static IAktionen aktionenManager;
private AktionenListListFragment listFragment;
#Override
public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "ListFragmentActivity created");
super.onCreate(savedInstanceState);
setContentView(R.layout.articlelist);
shoppinglistManager = new Shoppinglist(this);
aktionenManager = new Aktionen(this);
buttonSearch = (Button) findViewById(R.id.search_Button);
buttonSearch.setOnClickListener(searchListAktionen);
//show all entries on start
listFragment = new AktionenListListFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_articlelist, listFragment).commit();
}
OnClickListener searchListAktionen = new OnClickListener() {
public void onClick(View v) {
try{
searchString = (TextView) findViewById(R.id.input_search_bezeichnung);
search = searchString.getText().toString().trim();
Log.d(TAG, "search Button clicked "+search);
if(search.trim().length()==0){
search=null;
}
//show all entries on start
listFragment = new AktionenListListFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_articlelist, listFragment).commit();
}catch(Exception ex){
ex.printStackTrace();
}
}
};
Thanks in advance,
update:
thank you for your answers. I tried to implement them, but the main problem seems to be nowthat the onCreate and onActivityCreated method in the ListFragment are called twice (as I can see in my log messages).
my new code:
#Override
public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "ListFragmentActivity created");
super.onCreate(savedInstanceState);
//force commit
getSupportFragmentManager().executePendingTransactions();
if(getSupportFragmentManager().findFragmentByTag(tag) == null) {
setContentView(R.layout.articlelist);
shoppinglistManager = new Shoppinglist(this);
aktionenManager = new Aktionen(this);
buttonSearch = (Button) findViewById(R.id.search_Button);
buttonSearch.setOnClickListener(searchListAktionen);
listFragment = new AktionenListListFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_articlelist, listFragment,tag).commit();
}else{
Log.d(TAG, "ListFragment already exists");
}
}
I tried to set a unique tag for my ListFragment but this solution does not work.
I guess that one of the ListFragments is displayed in the background and the other is updated.
So first you need to stop making new ListFragments everytime your list is refreshed and just have a public method in your ListFragment that the Activity can call to restart the loader with the proper parameters. Then:
In your onLoadFinished(),
you should make a new adapter with the list you want to replace it with
myAdapter = new AktionenListCustomCursorAdapter(getActivity(), myCursor);
and call:
this.getListView().setAdapter(myAdapter);
So:
public void onLoadFinished(Loader<Cursor> mAdapter, Cursor myCursor) {
if(myCursor!=null){
//getting the data from the database
Log.d(TAG, "search String "+AktionenListFragmentActivity.search);
if(AktionenListFragmentActivity.search==null){
myCursor = AktionenListFragmentActivity.aktionenManager.fetchAllArticles();
}else{
myCursor = AktionenListFragmentActivity.aktionenManager.fetchItemsByBezeichnung(AktionenListFragmentActivity.search);
}
myAdapter = new AktionenListCustomCursorAdapter(getActivity(), myCursor);
this.getListView().setAdapter(myAdapter);
}
}
Hopefully this solved your question as I understood it. If you have any questions please leave it in the comment below and I will expand my answer. If it worked for you please accept answer. :D
well i'm having some problem with android. Maybe its simple but i'm pretty new in android world (3, 4 days actually). Well i have an activity whitch runs an asyncTask that stands to reading data from a sensor network. The async Task only executes the function l.read() that by itself is a loop and keep allways "earing" the sensor network and when a new node joins to the sensor network, it tells the UI thread that one more node has joined, and so it has to update the view (witch has just one tab saying that no nodes exists and will now have to have one node available - besides this i even have to load an xml layout file for this tab ) the problem is that, when i preform the function that supostly creates a view and add a tab (that is properly working because when i call it on onCreate it works) the app do not respond anymore, however, Logcat gives me no errors. It look like it works but it is not showing anything.
Please, i dont expect you to read all this code, its just to hel to explain my problem. Its been 2 days and i'm still asking for a solution..
main Activity:
public class PrincipalActivity extends Activity implements OnClickListener
{
private Button Send;
private Button Options;
private TextView ERROR;
private Bundle extras;
private String IP;
private String PORT;
private TabHost tabs;
private ligação l;
View m_vForm;
TabHost tabHost;
CustomView Cview;
ReadsData read;
//constructor
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
CustomView vv = new CustomView(PrincipalActivity.this,0);
setContentView(vv);
//instanciating the objects
IP = new String();
PORT = new String();
extras = getIntent().getExtras();
IP = extras.getString("IP"); //get the IP and port from the previous activity
PORT = extras.getString("PORT");
ERROR = (TextView) findViewById(R.id.ERROR);
tabs = (TabHost) findViewById(R.id.tabhost);
tabs.setup();
Send = (Button) findViewById(R.id.SendCommand);
Send.setOnClickListener(this);
Options = (Button) findViewById(R.id.Options);
Options.setOnClickListener(this);
//=========================
CreateAView("No Nodes",false);
l = new ligação(IP, Integer.parseInt(PORT),this); //CLASS LIGAÇÃO
// RunnableThread rT1 = new RunnableThread("t1",l,this);
read = new ReadsData();
read.execute();
//Textviews (Values)
}
public void AddUpdateNodes(Nodes n,int func)
{
//func is 0 if it it to add a node or 1 if it is to update an existing one
if(func == 0)
{
String s = new String();
s+= n.GETSourceNodeID();
CreateAView(s, true);
Cview.addNewNode(n);
}
if(func == 1)
Cview.UpdateNodeInformation(n);
}
public void onClick(View v)
{
if(v == Send)
{
// if i call CreateAView here it works ok
ERROR.setText(IP);
}
if(v == Options)
{
ERROR.setText(PORT);
}
}
// CREATING A VIEW WITH THE TABS
public void CreateAView(String s,boolean nodesAvailable)
{
m_vForm = createTABForm(s,nodesAvailable);
setContentView(m_vForm);
}
private ViewGroup createTABForm(String s,boolean nodesAvailable1)
{
final boolean nodesAvailable = nodesAvailable1;
// construct the TAB Host
tabHost = new TabHost(this);
tabHost.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT) );
// the tabhost needs a tabwidget, that is a container for the visible tabs
TabWidget tabWidget = new TabWidget(this);
tabWidget.setId(android.R.id.tabs);
tabWidget.setBackgroundColor(Color.BLUE);
tabHost.addView(tabWidget, new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) );
// the tabhost needs a frame layout for the views associated with each visible tab
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setId(android.R.id.tabcontent);
frameLayout.setPadding(0, 65, 0, 0);
tabHost.addView(frameLayout, new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) );
// setup must be called if you are not initialising the tabhost from XML
tabHost.setup();
// create the tabs
TabSpec ts = tabHost.newTabSpec("TAB_TAG_2");
ts.setIndicator(s); // creating a tabb with the specified name
ts.setContent(new TabHost.TabContentFactory(){
public View createTabContent(String tag)
{
// -- this tab contains a single control - the listview -- //
Cview = new CustomView(PrincipalActivity.this,nodesAvailable);
return Cview; // IS AN OBJECT FROM THE CLASS CustomView
}
});
tabHost.addTab(ts);
return tabHost;
}
////////////////////////////////////////////////////////////////
//Async Tasks
private class ReadsData extends AsyncTask
{
#Override
protected Object doInBackground(Object... params)
{
l.read();
return null;
}
protected void onPostExecute()
{
l.SocketClosed_();
}
}
}
//CLASS CUSTOM VIEW
public CustomView(Context context,boolean NodesAvailable)
{
super(context);
if(NodesAvailable) //loads a layout
{
LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=layoutInflater.inflate(R.layout.finallayout,this);
//only after inflate
ADC0 = (TextView) findViewById(R.id.ADC00);
}
else // loads another layout
{
LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=layoutInflater.inflate(R.layout.no_nodes,this);
}
}
public void addNewNode(Nodes n)
{
String s = new String();
s = new String();
s += n.GETSensores(0).GETvalor();
ADC0.setText(s);
}
public void UpdateNodeInformation(Nodes n)
{
String s = new String();
s += n.GETSourceNodeID();
//if(s.equals())
}
}
//SOME CODE OF LIGAÇÃO CLASS
public class ligação
{
protected PrincipalActivity cont;
//Constructors
public ligação(String ss,int Port,PrincipalActivity c){ s=ss; p=Port;cont = c; }
public void read()
{
while(flag)
{
...
cont.AddUpdateNodes(node, 0);
...
}
Many thanks in advance
it's weird that your app doesn't crash , since all UI operations should be done on the UI thread . maybe it's because the asynctask's thread has crashed but not the ui thread , and that's why nothing occurs.
anyway , in order to create/update the view within the asyncTask , you can use any of the following , which will post something to the UI thread to do as soon as it can :
use a handler.
use publishProgress.
use runOnUiThread.
I have a TabActivity with 4 tabs. When clicking on a button within one of the tabs and starting a new Activity (a new Activity not within the TabHost), the new Activity does not register OnClick(). The new Activity can't even show a Toast wich makes me think the TabHost is somehow blocking the ui?
When putting the Activity as one of the Tabs the OnClick works just fine.
Any ideas what the reason for this is?
I've included 3 classes:
1) The TabActivity
2) The Activity in a tab that starts:
3) The new Activity that cannot register OnClick()
1) TabActivity:
public class OverView extends TabActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_overview);
/** TabHost will have Tabs */
TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
/** TabSpec used to create a new tab.
* By using TabSpec only we can able to setContent to the tab.
* By using TabSpec setIndicator() we can set name to tab. */
/** tid1 is firstTabSpec Id. Its used to access outside. */
TabSpec Search = tabHost.newTabSpec("tid1");
TabSpec AllArtists = tabHost.newTabSpec("tid1");
TabSpec Favorites = tabHost.newTabSpec("tid1");
TabSpec About = tabHost.newTabSpec("tid1");
/** TabSpec setIndicator() is used to set name for the tab. */
Search. setIndicator("Search");
AllArtists. setIndicator("AllArtists");
Favorites. setIndicator("Favorites");
About. setIndicator("About");
/** TabSpec setContent() is used to set content for a particular tab. */
Search.setContent (new Intent(this, Search.class));
AllArtists.setContent (new Intent(this, AllArtists.class));
Favorites.setContent (new Intent(this, Favorites.class));
About.setContent (new Intent(this, About.class));
/** Add tabSpec to the TabHost to display. */
tabHost.addTab(Search);
tabHost.addTab(AllArtists);
tabHost.addTab(Favorites);
tabHost.addTab(About);
}
}
2) AllArtists (The Activity within the tab. Clicking a list item starts a new Activity):
public class AllArtists extends Activity {
// Debug
private final String TAG = this.getClass().getSimpleName();
// XML
EditText searchBox;
ListView listView;
// Adapter
ListAdapter listAdapter;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_allartists);
listAdapter = new ListAdapter(this, null);
// XML
listView = (ListView)findViewById(R.id.allartists_listview);
searchBox = (EditText)findViewById(R.id.allartists_searchbox);
listView.setAdapter(listAdapter);
listView.setFastScrollEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String memberID = (String)listAdapter.getID(position).toString();
if (!memberID.equals("HEADER")){
Log.d(TAG, "Jumping to Artists.class");
Intent intentArtist = new Intent (AllArtists.this, Artist.class);
intentArtist.putExtra("ID", memberID);
startActivity(intentArtist);
}
}
});
}
3) Artist (The new Activity started. This class does not register OnClick):
public class Artist extends Activity implements OnClickListener{
// Debug
private final String TAG = this.getClass().getSimpleName();
// XML
Button favorite_btn;
LinearLayout tel;
LinearLayout mob;
LinearLayout email;
LinearLayout www1;
LinearLayout www2;
LinearLayout add;
TextView name_tv;
TextView tel_tv;
TextView mob_tv;
TextView email_tv;
TextView www_tv1;
TextView www_tv2;
// Strings
String memberID;
String sirName;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_artist);
Toast.makeText(this, "OK, your in Activity_Artist..", Toast.LENGTH_SHORT);
// XML
favorite_btn = (Button)findViewById(R.id.artist_ib_favorite);
tel = (LinearLayout)findViewById(R.id.artist_tel_container);
mob = (LinearLayout)findViewById(R.id.artist_mob_container);
email = (LinearLayout)findViewById(R.id.artist_email_container);
www1 = (LinearLayout)findViewById(R.id.artist_www_container1);
www2 = (LinearLayout)findViewById(R.id.artist_www_container2);
add = (LinearLayout)findViewById(R.id.artist_add_container);
name_tv = (TextView)findViewById(R.id.artist_tv_name);
tel_tv = (TextView)findViewById(R.id.artist_tel_dynamic);
mob_tv = (TextView)findViewById(R.id.artist_mob_dynamic);
email_tv = (TextView)findViewById(R.id.artist_email_dynamic);
www_tv1 = (TextView)findViewById(R.id.artist_www_dynamic1);
www_tv2 = (TextView)findViewById(R.id.artist_www_dynamic2);
// OnClickListeners
favorite_btn.setOnClickListener(this);
tel.setOnClickListener(this);
mob.setOnClickListener(this);
email.setOnClickListener(this);
www1.setOnClickListener(this);
www2.setOnClickListener(this);
add.setOnClickListener(this);
// Code here to get memberID for fillContent()
}
private void fillContent(String memberID) throws JSONException {
// Code here to fill the TextViews etc with content from the DataBase.
}
#Override
public void onClick(View v) {
switch (v.getId()){
case R.id.artist_ib_favorite:
Toast.makeText(this, "onClick", Toast.LENGTH_SHORT);
Log.d(TAG, "Neo is attempting to insert member into favorites");
MyDB db = new MyDB(this);
db.insertFavorite(memberID, sirName);
break;
case R.id.artist_tel_container:
break;
case R.id.artist_mob_container:
Log.d(TAG, "OMG CLICKED THE MOBILE!");
break;
case R.id.artist_email_container:
break;
case R.id.artist_www_container1:
break;
case R.id.artist_add_container:
break;
}
}
Thanks ;)
For Toast you need to call show.
Toast.makeText(this, "OK, your in Activity_Artist..", Toast.LENGTH_SHORT).show();
For the click Operation on anything apart from Button you need to define
android:clickable="true"
in the layout.
Solved this. In the layout there was an (empty) GridView at the bottom of the layout set to android:layout_height="fill_parent" wich stole the touchevent.
The weird part about this is that when putting the exact same activity with the exact same XML inside a tab, the onClick() worked fine.