I have a tabhost with several tabs and each tab contain a certain number of operations which are listed in a listview. To populate that listview I use an ArrayList.
First time tabs are created evertything works fine. The issue comes when I try to filter the list by year. The process of filtering works fine as I can see the filtered list in debug and it's fine.
The issue is that after filtering, i recreate the tabs in order to fill all listviews again. To open tabs I use this code. It creates as many tabs as different currencies there are in the list:
public static void openFragments(FragmentTabHost tabHost, ArrayList<Posicion> positions, Class FragmentResumen, Class FragmentDetails ) {
//==========================================================================================
// This method open as many tabs as different currencies there are in positions list
//==========================================================================================
ArrayList<String> currencies = Currency.getDifferentCurrencies(positions);
tabHost.clearAllTabs();
for (int i = 0; i < currencies.size() + 1; i++) {
String tabName = "", tabSpec = "";
Class fragmentToOpen;
Bundle arg1 = new Bundle();
//A general tab is first created
if (i == 0)
{
tabName = "All";
tabSpec = "General";
arg1.putString("moneda", tabName);
arg1.putSerializable("posiciones", positions);
fragmentToOpen = FragmentResumen;
}
//The rest of tabs for currencies are created
else
{
tabName = currencies.get(i - 1);
tabSpec = "Tab" + (i - 1);
arg1.putString("moneda", tabName);
arg1.putSerializable("posiciones", positions);
fragmentToOpen = FragmentDetails;
}
tabHost.addTab(tabHost.newTabSpec(tabSpec).setIndicator(tabName), fragmentToOpen, arg1);
}
}
As I told before, this works fine always.
First time I need to create tabs I call it by using:
openFragments(tabHost, positions, FragmentResumenMedio.class, FragmentDetailsMedio.class);
Then I have a button that shows a DatePicker and when user selects a year I close the dialog and redraw tabs as follows:
ArrayList<Posicion> positionsFiltered = General.makeHardCopyOfArrayListPosition(positions);
for(Posicion posicion : positionsFiltered)
{
Boolean matchFilters = filterPositionsByYear(posicion, year + "");
if(matchFilters == false){
positions.remove(posicion);
}
}
General.openFragments(tabHost, positions, FragmentResumenMedio.class, FragmentDetailsMedio.class);
When I debug this last function I can see that positions have the correct value after filtering but when I click the new tab, it shows the list without filtering and I don't know how could I solve this issue.
Thanks a lot.
EDIT
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//Initialize view and tabhost
View rootView = inflater.inflate(R.layout.fragment_medio, container, false);
tabHost = (FragmentTabHost) rootView.findViewById(android.R.id.tabhost);
tabHost.setup(getActivity(), getChildFragmentManager(), android.R.id.tabcontent);
return tabHost;
}
#Override
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//onCreatedView is only called the first time so we must ensure that tabhost is not null before adding tabs
if(tabHost == null) {
tabHost = (FragmentTabHost) getView().findViewById(android.R.id.tabhost);
tabHost.setup(getActivity(), getChildFragmentManager(), android.R.id.tabcontent);
}
FloatingActionButton floatingActionButton = (FloatingActionButton) getView().findViewById(R.id.floatingButton);
floatingActionButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
positions = new ArrayList<>(positionsFiltered);
createDialogWithoutDateField().show();
}
});
//Check if any update has been made since the last open
SharedPreferences prefs = getActivity().getPreferences(MODE_PRIVATE);
Boolean updateMedioRequired = prefs.getBoolean(updateOperationsMedioPlazo, true);
if (updateMedioRequired != null)
{
if (updateMedioRequired == true)
{
//Update variable that indicates if changes have been made or not
SharedPreferences.Editor editor = getActivity().getPreferences(MODE_PRIVATE).edit();
editor.putBoolean(updateOperationsMedioPlazo, false);
editor.apply();
//Check if there are previously stored operations
if (operations.size() > 0)
{
//Show a progressDialog as prices have to be downloaded from internet and this can be a time consumming task
progress = ProgressDialog.show(getActivity(), "Obteniendo precios",
"Un momento por favor...", true);
//Generate positions from operations list and wait for result in "onStockPriceResult". If there are no changes, positions variable has already values
if(positions.size() == 0) {
new Thread(new Runnable() {
#Override
public void run() {
positions = MedioPlazoCalculations.generatePositions(listener, getActivity(), operations);
}
}).start();
}
}
else
{
Toast.makeText(getActivity(), "Aún no se ha introducido ninguna operación", Toast.LENGTH_LONG).show();
}
}
else
{
//If no update needed, variable coming from MainActivity has positionList. Open as many new fragments as currencies there are in positionsList
General.openFragments(tabHost, positions, FragmentResumenMedio.class, FragmentDetailsMedio.class);
}
}
}
EDIT 2:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
{
if(getActivity()!=null)
{
Bundle bundle = this.getArguments();
positions = (ArrayList<Posicion>) bundle.getSerializable("posiciones");
moneda = (String) bundle.getString("moneda");
}
}
}
Edit 3: If I place the commented instruction, filtering does not work. If I remove it, filtering works but I cant filter again because the value of the list has the filtered version not the original one
floatingActionButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
positions = new ArrayList<>(positionsFiltered);
createDialogWithoutDateField().show();
}
});
Related
For a reason no elements get changed and some do not.
A Fragment called QuestionFragment is in an Action called QuizAction.
The fragment gets replaced in the OnCreate of the Action.
In the fragment I try to add radiobuttons and change text but all fail.
All text that involves "it works" do work and do change the fragment elements.
All text tot involve "it does not work" do not change anything.
What am I doing wrong?
personally: I guess it has to do with the first fragment declared in the xml file of the activity that is actually edited but the second one does not. The one that I should see but never actually do. I also do not know how to check this.
Anyhow this is my code.
In OnCreate of the activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
if (manager == null) manager = getSupportFragmentManager();
Bundle args = new Bundle();
args.putStringArray("Possible Ansers", PossibleAnsers);
args.putSerializable("protocol", p);
fragment = new QuestionFragment();
fragment.setArguments(args);
ft= manager.beginTransaction();
ft.replace(R.id.fragment,fragment).commit();
}
In the onViewCreated of the QuestionFragment:
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
Bundle bundle = getArguments();
String[] antw = new String[0];
rg = (RadioGroup) getView().findViewById(R.id.radioGroup);
tv = (TextView) getView().findViewById(R.id.smallTekst);
tv.setText("works");
if(bundle != null) {
if( bundle.getStringArray("PossibleAnsers") != null) {
antw = bundle.getStringArray("PossibleAnsers");
}
}
for(int i = 0; i < antw.length; i++) {
addRadioButton(c, rg, "radiobutton "+i +"that doesn't work");
Toast.makeText(c, "rdm toast that works", Toast.LENGTH_LONG).show();
tv.setText("Doesn't work");
}
addRadioButton(c, rg, "working radioButton");
super.onViewCreated(view, savedInstanceState);
}
Already a big thanks.
So im quite new to Android Studio and app development in general and i had this issue for a while, with no luck of fixing it. I've figured that someone here might provide some ideas for fixing this..
Issue: The refreshing of ListView on UI thread (as suggested here) does not work for me. Here's the declaration of 'Runnable run' (in MainActivity.java):
public Runnable run;
// ...
run = new Runnable() {
public void run() {
ArrayList<String> temp1 = (ArrayList<String>) arrayList_1.clone();
View v = getLayoutInflater().inflate(R.layout.fragment_main, null);
lv_1 = (ListView) v.findViewById(R.id.listViewMe);
lv_1.setAdapter(adapter_1);
arrayList_1.clear();
arrayList_1.addAll(temp1);
adapter_1.notifyDataSetChanged();
lv_1.invalidateViews();
lv_1.refreshDrawableState();
Log.e("gig", "DONE REFRESHING");
}
};
I call the method here:
#Override
public boolean onNavigationItemSelected(MenuItem item)
{
int id = item.getItemId();
Fragment fragment = null;
if (id == R.id.nav_main) {
fragment = new FragmentMain();
} if (id == R.id.nav_history) {
fragment = new FragmentHistory();
}
if (fragment != null)
{
FragmentTransaction localFragmentTransaction = getSupportFragmentManager().beginTransaction();
localFragmentTransaction.replace(R.id.screen_area, fragment);
localFragmentTransaction.commit();
runOnUiThread(run); // here
}
((DrawerLayout) findViewById(R.id.drawer_layout)).closeDrawer(GravityCompat.START);
return true;
}
Now for the part that's confusing me: it works when i add a new item to the ListView via this method:
public void addDebtToOther(String name, String money)
{
String full = name + ", " + money + " EUR";
lv_1 = (ListView) findViewById(R.id.listViewMe);
if (lv_1!=null) {
lv_1.setAdapter(adapter_1);
arrayList_1.add(full);
adapter_1.notifyDataSetChanged();
} else {
Log.e("gig", "ListView error, lv is NULL");
}
}
That's about it, any help would be really apriciated!
In the run object, a new View is inflated, but as far as I can tell, it's not being added to the Activity's contentView or any of it's children, so it is just a View somewhere in memory that isn't being rendered onto the screen.
Did you mean to do something like this instead?:
public Runnable run;
// ...
run = new Runnable() {
public void run() {
ArrayList<String> temp1 = (ArrayList<String>) arrayList_1.clone();
// View v = getLayoutInflater().inflate(R.layout.fragment_main, null);
// lv_1 = (ListView) v.findViewById(R.id.listViewMe);
lv_1 = (ListView) findViewById(R.id.listViewMe);
lv_1.setAdapter(adapter_1);
arrayList_1.clear();
arrayList_1.addAll(temp1);
adapter_1.notifyDataSetChanged();
lv_1.invalidateViews();
lv_1.refreshDrawableState();
Log.e("gig", "DONE REFRESHING");
}
};
Ok so after about a week of head-banging, with the help of #Eric i've figured it out. Turns out i needed to call the run() method in my fragment's .onStart(), like this:
#Override
public void onStart() {
super.onStart();
((MainActivity)getContext()).run.run();
}
Thanks again Eric!
Hello guys I am for first time here so if there are some mistakes with my problem just notify me to correct my self. My problem is in the adapter I think. My application is with 3 fragment tabs. In each tab I have a ListView with some items. Also I have button in each tab that updates,deletes or adds items. I make that by popping up an AleartDialog for adding a new item or clicking on the item from the list to update it or delete it. So after I login in my application I can do what ever I want with that list. Its not a problem. I can rotate the screen and my list still updates. Changing the tabs its not a problem also. The problem comes when I go to other fragment I click on the button for adding or on some of the items for updating and the AleartDialog pops up. After that when I close it I return to the first tab. Trying to add an item doesn't update the list and I see the same items. Deleting the item from the list then throws exception IndexOutOfBounds because the item its not in the list. I think I use arrayAdapter.notifyDataSetChanged() properly. Here I will share some other code.
Like that I update my list. In the jsonObject is list the with the items.
private void fillList(Gson gson, String jsonObject) {
listWithNames.clear();
Type collectionType = new TypeToken<ArrayList<PersonalSaveDTO>>() {
}.getType();
personalSaveList = gson.fromJson(jsonObject, collectionType);
Log.wtf(TAG, "OT REQUEST: " + personalSaveList);
for (int i = 0; i < personalSaveList.size(); i++) {
listWithNames.add(personalSaveList.get(i).getName());
}
Log.wtf(TAG, "fillList: " + listWithNames);
getActivity().runOnUiThread(new Runnable() {
#Override
public void run() {
arrayAdapter.notifyDataSetChanged();
buttonEnable(true);
}
});
}
Like that I starts the fragment.
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View viewFragment = inflater.inflate(R.layout.user_fragment, container, false);
listViewUser = (ListView) viewFragment.findViewById(R.id.listViewForUser);
addItem = (Button) viewFragment.findViewById(R.id.buttonAddUserElements);
updateList = (Button) viewFragment.findViewById(R.id.refreshListUser);
updateList.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
makeRequestForList(viewFragment);
}
});
addItem.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
addElement(viewFragment);
}
});
configureArrayAdapter(viewFragment);
setListenerForUserList(viewFragment);
if (savedInstanceState != null) {
isRequestMade = savedInstanceState.getBoolean("isRequestMade");
listWithNames = savedInstanceState.getStringArrayList("listWithNames");
personalSaveList = savedInstanceState.getParcelableArrayList("personalSaveList");
arrayAdapter.addAll(listWithNames);
arrayAdapter.notifyDataSetChanged();
}
if (!isRequestMade) {
makeRequestForList(viewFragment);
isRequestMade = true;
}
return viewFragment;
}
And here is how I create the adapter.
private void configureArrayAdapter(View view) {
listWithNames = new ArrayList<>();
arrayAdapter = new ArrayAdapter<String>(view.getContext(),
R.layout.list_personal_group_fragment, R.id.adapterFragmentPersonalGroups, listWithNames);
arrayAdapter.clear();
listViewUser.setAdapter(arrayAdapter);
}
I am following this tutorial.
there are 3 tabs in my App. in tab3 I m making changes to some views (like buttons and EditText spinners etc) and on the behalf of these changes i have to perform some actions in tab2. Simply you can say that i Change some values in tab3 and effect takes places in tab2. I know how to do this. I just want that my values of view becomes resets every time to default values when switching between the tab2 and tab3
My question is that how can i save the states of my views. so that on resuming the tabs i must get the default look of my views as i had left previously.
One thing more i tell you that i m doing all the work in onCreateView() methos. is this correct way. like this.
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Toast.makeText(getActivity(), "onCreateView", Toast.LENGTH_SHORT)
.show();
if (container == null) {
return null;
}
View vi = inflater.inflate(R.layout.settings, container, false);
btnInsert = (Button) vi.findViewById(R.id.btnInsert);
btnInsert.setOnClickListener(this);
btnPosition = (Button) vi.findViewById(R.id.btnPosition);
btnPosition.setOnClickListener(this);
txtPosition = (TextView) vi.findViewById(R.id.txtPosition);
txtLogo = (TextView) vi.findViewById(R.id.txtLogo);
imgLogoPreview = (ImageView) vi.findViewById(R.id.imgLogoPreview);
imgLogoPreview.setOnClickListener(this);
edTxtUserText = (EditText) vi.findViewById(R.id.edTxtPreview);
relLogo = (RelativeLayout) vi.findViewById(R.id.RelLogo);
relText = (RelativeLayout) vi.findViewById(R.id.RelText);
logoWheel = (WheelView) vi.findViewById(R.id.wheelLogo);
logoWheel.setAdapter(new ArrayWheelAdapter<String>(logoWheelList));
logoWheel.setVisibleItems(4);
logoWheel.setCurrentItem(1);
positionWheel = (WheelView) vi.findViewById(R.id.wheelPosition);
positionWheel.setAdapter(new ArrayWheelAdapter<String>(
positionWheelTextList));
// LogoWheel changed listener
changedListenerLogo = new OnWheelChangedListener() {
public void onChanged(WheelView wheel, int oldValue, int newValue) {
if (!wheelScrolled) {
}
}
};
logoWheel.addChangingListener(changedListenerLogo);
// Wheel scrolled listener
scrolledListenerLogo = new OnWheelScrollListener() {
public void onScrollStarts(WheelView wheel) {
wheelScrolled = true;
}
public void onScrollEnds(WheelView wheel) {
wheelScrolled = false;
btnInsert.setText(logoWheelList[wheel.getCurrentItem()] + "");
wheel.setVisibility(View.INVISIBLE);
if (wheel.getCurrentItem() == 2) {
txtPosition.setVisibility(View.INVISIBLE);
btnPosition.setVisibility(View.INVISIBLE);
relText.setVisibility(View.INVISIBLE);
relLogo.setVisibility(View.INVISIBLE);
} else if (wheel.getCurrentItem() == 1) {
relText.setVisibility(View.VISIBLE);
relLogo.setVisibility(View.INVISIBLE);
txtPosition.setVisibility(View.VISIBLE);
btnPosition.setVisibility(View.VISIBLE);
btnPosition.setText("Top");
positionWheel.setAdapter(new ArrayWheelAdapter<String>(
positionWheelTextList));
positionWheel.setVisibleItems(4);
positionWheel.setCurrentItem(1);
} else if (wheel.getCurrentItem() == 0) {
relLogo.setVisibility(View.VISIBLE);
relText.setVisibility(View.INVISIBLE);
txtPosition.setVisibility(View.VISIBLE);
btnPosition.setVisibility(View.VISIBLE);
btnPosition.setText("Top Left");
positionWheel.setAdapter(new ArrayWheelAdapter<String>(
positionWheelLogoList));
positionWheel.setVisibleItems(4);
positionWheel.setCurrentItem(1);
}
}
};
logoWheel.addScrollingListener(scrolledListenerLogo);
// /////////////////////Positon Wheel Listners///////////
// LogoWheel changed listener
changedListenerPosition = new OnWheelChangedListener() {
public void onChanged(WheelView wheel, int oldValue, int newValue) {
if (!wheelScrolled) {
}
}
};
positionWheel.addChangingListener(changedListenerPosition);
// Wheel scrolled listener
scrolledListenerPosition = new OnWheelScrollListener() {
public void onScrollStarts(WheelView wheel) {
wheelScrolled = true;
}
public void onScrollEnds(WheelView wheel) {
wheelScrolled = false;
String btnStatus = btnInsert.getText().toString();
if (btnStatus.equals("Logo")) {
btnPosition.setText(positionWheelLogoList[positionWheel
.getCurrentItem()] + "");
} else if (btnStatus.equals("Text")) {
btnPosition.setText(positionWheelTextList[positionWheel
.getCurrentItem()] + "");
}
wheel.setVisibility(View.INVISIBLE);
}
};
positionWheel.addScrollingListener(scrolledListenerPosition);
return vi;
}
at what point i must save the states and at what point i should retrieve the savedstates?
Please tell me the how to implement the lifecycle of fragment in simple words.
i also tried the saveInstance() method of fragment. but not called.
Thanks
If I understand you correctly then this might be useful. Instead of recreating Fragments each time you can hide and show them.
This of course preserves your Fragments so is possibly only something you'd do it you had a few tabs. The advantage of this is that
You don't need to worry about saving data and recreating the fragment
Changes are available immediately to the user as soon as the relevant tab is selected.
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.