Search Results

Search found 159 results on 7 pages for 'kbargais lv'.

Page 4/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Android how to match text with images by pointing text and images with lines

    - by Shirisha
    I am trying to create app which is match text with appropriate images by pointing with line. I want to create app exactly same which is shown in the below image: can any one please give me an idea? This is my main class: public class MatchActivity extends Activity { ArrayAdapter<String> listadapter; float x1; float y1; float x2; float y2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String[] s1 = { "smiley1", "smiley2", "smiley3" }; ListView lv = (ListView) findViewById(R.id.text_list); ArrayList<String> list = new ArrayList<String>(); list.addAll(Arrays.asList(s1)); listadapter = new ArrayAdapter<String>(this, R.layout.rowtext, s1); lv.setAdapter(listadapter); GridView gv = (GridView) findViewById(R.id.image_list); gv.setAdapter(new ImageAdapter(this)); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3){ x1=v.getX(); y1=v.getY(); Log.d("list","text positions x1:"+x1+" y1:"+y1); } }); gv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3){ DrawView draw=new DrawView(MatchActivity.this); x2=v.getX(); y2=v.getY(); draw.position1.add(x1); draw.position1.add(y1); draw.position2.add( x2); draw.position2.add(y2); Log.d("list","image positions x2:"+x2+" y2:"+y2); LinearLayout ll=LinearLayout)findViewById(R.id.draw_line); ll.addView(draw); } }); } } This is my drawing class to draw a line: public class DrawView extends View { Paint paint = new Paint(); private List<Float> position1=new ArrayList<Float>(); private List<Float> position2=new ArrayList<Float>();; public DrawView(Context context) { super(context); invalidate(); Log.d("drawview","In DrawView class position1:"+position1+" position2:"+position2) ; } @Override public void onDraw(Canvas canvas) { super.onDraw(canvas); Log.d("on draw","IN onDraw() position1:"+position1+" position2:"+position2); assert position1.size() == position2.size(); for (int i = 0; i < position1.size(); i += 2) { float x1 = position1.get(i); float y1 = position1.get(i + 1); float x2 = position2.get(i); float y2 = position2.get(i + 1); paint.setColor(Color.BLACK); paint.setStrokeWidth(3); canvas.drawLine(x1,y1, x2,y2, paint); } } } Thanks in advance .

    Read the article

  • MVVM Madness: Commands

    - by JP
    I like MVVM. I don't love it, but like it. Most of it makes sense. But, I keep reading articles that encourage you to write a lot of code so that you can write XAML and don't have to write any code in the code-behind. Let me give you an example. Recently I wanted to hookup a command in my ViewModel to a ListView MouseDoubleClickEvent. I wasn't quite sure how to do this. Fortunately, Google has answers for everything. I found the following articles: http://blog.functionalfun.net/2008/09/hooking-up-commands-to-events-in-wpf.html http://joyfulwpf.blogspot.com/2009/05/mvvm-invoking-command-on-attached-event.html http://sachabarber.net/?p=514 http://geekswithblogs.net/HouseOfBilz/archive/2009/08/27/adventures-in-mvvm-ndash-binding-commands-to-any-event.aspx http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/ While the solutions were helpful in my understanding of commands, there were problems. Some of the aforementioned solutions rendered the WPF designer unusable because of a common hack of appending "Internal" after a dependency property; the WPF designer can't find it, but the CLR can. Some of the solutions didn't allow multiple commands to the same control. Some of the solutions didn't allow parameters. After experimenting for a few hours I just decided to do this: private void ListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListView lv = sender as ListView; MyViewModel vm = this.DataContext as MyViewModel; vm.DoSomethingCommand.Execute(lv.SelectedItem); } So, MVVM purists, please tell me what's wrong with this? I can still Unit test my command. This seems very practical, but seems to violate the guideline of "ZOMG... you have code in your code-behind!!!!" Please share your thoughts. Thanks in advance.

    Read the article

  • ICollectionView.SortDescriptions sort does not work if underlying DataTable has zero rows

    - by BigBlondeViking
    We have a WPF app that has a DataGrid inside a ListView. private DataTable table_; We do a bunch or dynamic column generation ( depending on the report we are showing ) We then do the a query and fill the DataTable row by row, this query may or may not have data.( not the problem, an empty grid is expected ) We set the ListView's ItemsSource to the DefaultView of the DataTable. lv.ItemsSource = table_.DefaultView; We then (looking at the user's pass usage of the app, set the sort on the column) Sort Method below: private void Sort(string sortBy, ListSortDirection direction) { ICollectionView dataView = CollectionViewSource.GetDefaultView(lv.ItemsSource); dataView.SortDescriptions.Clear(); var sd = new SortDescription(sortBy, direction); dataView.SortDescriptions.Add(sd); dataView.Refresh(); } In the Zero DataTable rows scenario, the sort does not "hold"? and if we dynamically add rows they will not be in sorted order. If the DataTable has at-least 1 row when the sort is applied, and we dynamically add rows to the DataTable, the rows com in sorted correctly. I have built a standalone app that replicate this... It is an annoyance and I can add a check to see if the DataTable was empty, and re-apply the sort... Anyone know whats going on here, and am I doing something wrong? FYI: What we based this off if comes from the MSDN as well: http://msdn.microsoft.com/en-us/library/ms745786.aspx

    Read the article

  • Sort on DataView does not work if DataTable has zero rows

    - by BigBlondeViking
    We have a WPF app that has a DataGrid insode a ListView. private DataTable table_; We do a bunch or dynamic column generation ( depending on the report we are showing ) We then do the a query and fill the DataTable row by row, this query may or may not have data.( not the problem, an empty grid is expected ) We set the ListView's ItemsSource to the DefaultView of the DataTable. lv.ItemsSource = table_.DefaultView; We then (looking at the user's pass usage of the app, set the sort on the column) Sort Method below: private void Sort(string sortBy, ListSortDirection direction) { var dataView = CollectionViewSource.GetDefaultView(lv.ItemsSource); dataView.SortDescriptions.Clear(); var sd = new SortDescription(sortBy, direction); dataView.SortDescriptions.Add(sd); dataView.Refresh(); } In the Zero DataTable rows scenario, the sort does not "hold"? and if we dynamically add rows they will not be in sorted order. If the DataTable has at-least 1 row when the sort is applied, and we dynamically add rows to the DataTable, the rows com in sorted correctly. I have built a standalone app that replicate this... It is an annoyance and I can add a check to see if the DataTable was empty, and re-sort... Anyone know whats going on here, and am I doing something wrong? FYI: What we based this off if comes from the MSDN as well: http://msdn.microsoft.com/en-us/library/ms745786.aspx

    Read the article

  • changing value of a textview while change in other textview by multiplying

    - by sur007
    Here I am getting parsed data from a URL and now I am trying to change the value of parse data to users only dynamically on an text view and my code is package com.mokshya.jsontutorial; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import com.mokshya.jsontutorialhos.xmltest.R; import android.app.AlertDialog; import android.app.ListActivity; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.EditText; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.Toast; public class Main extends ListActivity { EditText resultTxt; public double C_webuserDouble; public double C_cashDouble; public double C_transferDouble; public double S_webuserDouble; public double S_cashDouble; public double S_transferDouble; TextView cashTxtView; TextView webuserTxtView; TextView transferTxtView; TextView S_cashTxtView; TextView S_webuserTxtView; TextView S_transferTxtView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listplaceholder); cashTxtView = (TextView) findViewById(R.id.cashTxtView); webuserTxtView = (TextView) findViewById(R.id.webuserTxtView); transferTxtView = (TextView) findViewById(R.id.transferTxtView); S_cashTxtView = (TextView) findViewById(R.id.S_cashTxtView); S_webuserTxtView = (TextView) findViewById(R.id.S_webuserTxtView); S_transferTxtView = (TextView) findViewById(R.id.S_transferTxtView); ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); JSONObject json = JSONfunctions .getJSONfromURL("http://ldsclient.com/ftp/strtojson.php"); try { JSONArray netfoxlimited = json.getJSONArray("netfoxlimited"); for (inti = 0; i < netfoxlimited.length(); i++) { HashMap<String, String> map = new HashMap<String, String>(); JSONObject e = netfoxlimited.getJSONObject(i); map.put("date", e.getString("date")); map.put("c_web", e.getString("c_web")); map.put("c_bank", e.getString("c_bank")); map.put("c_cash", e.getString("c_cash")); map.put("s_web", e.getString("s_web")); map.put("s_bank", e.getString("s_bank")); map.put("s_cash", e.getString("s_cash")); mylist.add(map); } } catch (JSONException e) { Log.e("log_tag", "Error parsing data " + e.toString()); } ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.main, new String[] { "date", "c_web", "c_bank", "c_cash", "s_web", "s_bank", "s_cash", }, new int[] { R.id.item_title, R.id.webuserTxtView, R.id.transferTxtView, R.id.cashTxtView, R.id.S_webuserTxtView, R.id.S_transferTxtView, R.id.S_cashTxtView }); setListAdapter(adapter); final ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { @SuppressWarnings("unchecked") HashMap<String, String> o = (HashMap<String, String>) lv .getItemAtPosition(position); Toast.makeText(Main.this, "ID '" + o.get("id") + "' was clicked.", Toast.LENGTH_SHORT).show(); } }); resultTxt = (EditText) findViewById(R.id.editText1); resultTxt.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { // TODO Auto-generated method stub resultTxt.setText(""); } }); resultTxt.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub String text; text = resultTxt.getText().toString(); if (resultTxt.getText().length() > 5) { calculateSum(C_webuserDouble, C_cashDouble, C_transferDouble); calculateSunrise(S_webuserDouble, S_cashDouble, S_transferDouble); } else { } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } }); } private void calculateSum(Double webuserDouble, Double cashDouble, Double transferDouble) { String Qty; Qty = resultTxt.getText().toString(); if (Qty.length() > 0) { double QtyValue = Double.parseDouble(Qty); double cashResult; double webuserResult; double transferResult; cashResult = cashDouble * QtyValue; webuserResult = webuserDouble * QtyValue; transferResult = transferDouble * QtyValue; DecimalFormat df = new DecimalFormat("#.##"); String cashResultStr = df.format(cashResult); String webuserResultStr = df.format(webuserResult); String transferResultStr = df.format(transferResult); cashTxtView.setText(String.valueOf(cashResultStr)); webuserTxtView.setText(String.valueOf(webuserResultStr)); transferTxtView.setText(String.valueOf(transferResultStr)); // cashTxtView.setFilters(new InputFilter[] {new // DecimalDigitsInputFilter(2)}); } if (Qty.length() == 0) { cashTxtView.setText(String.valueOf(cashDouble)); webuserTxtView.setText(String.valueOf(webuserDouble)); transferTxtView.setText(String.valueOf(transferDouble)); } } private void calculateSunrise(Double webuserDouble, Double cashDouble, Double transferDouble) { String Qty; Qty = resultTxt.getText().toString(); if (Qty.length() > 0) { double QtyValue = Double.parseDouble(Qty); double cashResult; double webuserResult; double transferResult; cashResult = cashDouble * QtyValue; webuserResult = webuserDouble * QtyValue; transferResult = transferDouble * QtyValue; DecimalFormat df = new DecimalFormat("#.##"); String cashResultStr = df.format(cashResult); String webuserResultStr = df.format(webuserResult); String transferResultStr = df.format(transferResult); S_cashTxtView.setText(String.valueOf(cashResultStr)); S_webuserTxtView.setText(String.valueOf(webuserResultStr)); S_transferTxtView.setText(String.valueOf(transferResultStr)); } if (Qty.length() == 0) { S_cashTxtView.setText(String.valueOf(cashDouble)); S_webuserTxtView.setText(String.valueOf(webuserDouble)); S_transferTxtView.setText(String.valueOf(transferDouble)); } } } and I am getting following error on logcat 08-28 15:04:12.839: E/AndroidRuntime(584): Uncaught handler: thread main exiting due to uncaught exception 08-28 15:04:12.848: E/AndroidRuntime(584): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mokshya.jsontutorialhos.xmltest/com.mokshya.jsontutorial.Main}: java.lang.NullPointerException 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.access$2100(ActivityThread.java:116) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.os.Handler.dispatchMessage(Handler.java:99) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.os.Looper.loop(Looper.java:123) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.main(ActivityThread.java:4203) 08-28 15:04:12.848: E/AndroidRuntime(584): at java.lang.reflect.Method.invokeNative(Native Method) 08-28 15:04:12.848: E/AndroidRuntime(584): at java.lang.reflect.Method.invoke(Method.java:521) 08-28 15:04:12.848: E/AndroidRuntime(584): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 08-28 15:04:12.848: E/AndroidRuntime(584): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 08-28 15:04:12.848: E/AndroidRuntime(584): at dalvik.system.NativeStart.main(Native Method) 08-28 15:04:12.848: E/AndroidRuntime(584): Caused by: java.lang.NullPointerException 08-28 15:04:12.848: E/AndroidRuntime(584): at com.mokshya.jsontutorial.Main.onCreate(Main.java:111) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 08-28 15:04:12.848: E/AndroidRuntime(584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)

    Read the article

  • OpenSSL certificate lacks key identifiers

    - by 0xDEAD BEEF
    How do i add these sections to certificate (i am manualy building it using C++). X509v3 Subject Key Identifier: A4:F7:38:55:8D:35:1E:1D:4D:66:55:54:A5:BE:80:25:4A:F0:68:D0 X509v3 Authority Key Identifier: keyid:A4:F7:38:55:8D:35:1E:1D:4D:66:55:54:A5:BE:80:25:4A:F0:68:D0 Curently my code builds sertificate well, except for those keys.. :/ static X509 * GenerateSigningCertificate(EVP_PKEY* pKey) { X509 *x; x = X509_new(); //create x509 certificate X509_set_version(x, NID_X509); ASN1_INTEGER_set(X509_get_serialNumber(x), 0x00000000); //set serial number X509_gmtime_adj(X509_get_notBefore(x), 0); X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*365); //1 year X509_set_pubkey(x, pKey); //set pub key from just generated rsa X509_NAME *name; name = X509_get_subject_name(x); NAME_StringField(name, "C", "LV"); NAME_StringField(name, "CN", "Point"); //common name NAME_StringField(name, "O", "Point"); //organization X509_set_subject_name(x, name); //save name fields to certificate X509_set_issuer_name(x, name); //save name fields to certificate X509_EXTENSION *ex; ex = X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_cert_type, "server"); X509_add_ext(x,ex,-1); X509_EXTENSION_free(ex); ex = X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_comment, "example comment extension"); X509_add_ext(x, ex, -1); X509_EXTENSION_free(ex); ex = X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_ssl_server_name, "www.lol.lv"); X509_add_ext(x, ex, -1); X509_EXTENSION_free(ex); ex = X509V3_EXT_conf_nid(NULL, NULL, NID_basic_constraints, "critical,CA:TRUE"); X509_add_ext(x, ex, -1); X509_EXTENSION_free(ex); X509_sign(x, pKey, EVP_sha1()); //sign x509 certificate return x; }

    Read the article

  • I can not get the text from a selected item in a listview...pleeeeasss help.

    - by Miguel
    I always get an ClassCastException error... i do not what else to do... - I'm using a data biding concept to populated the listview from a sqlite3 database. - I just want to get the selected item text after a long press click. This is the code of the activity: public class ItemConsultaGastos extends ListActivity { private DataHelper dh ; TextView seleccion; private static String[] FROM = {DataHelper.MES, DataHelper.ANO}; private static int[] TO = {R.id.columnaMes, R.id.columnaAno }; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.muestrafechas); this.dh = new DataHelper(this); Cursor cursor = dh.selectAllMeses(); startManagingCursor(cursor); this.mostrarFechas(cursor); ListView lv = getListView(); lv.setOnItemLongClickListener(new OnItemLongClickListener(){ @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1,int row, long arg3) { //here is where i got the classCastException. String[] tmp = (String[]) arg0.getItemAtPosition(row); //tmp[0] ist the Text of the first TextView displayed by the clicked ListItem Log.w("Gastos: ", "El texto: " + tmp[0].toString()); return true; } }); } private void mostrarFechas(Cursor cursor) { SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,R.layout.muestrafechasitem,cursor, FROM, TO); setListAdapter(adapter); } } ///// This is the xml where a define the rows to show on the listview <TextView android:id="@+id/espacio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" " /> <TextView android:id="@+id/columnaAno" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:layout_toRightOf="@+id/espacio"/> <TextView android:id="@+id/separador1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" -- " android:layout_toRightOf="@+id/columnaAno" android:textSize="20sp" /> <TextView android:id="@+id/columnaMes" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@+id/separador1" android:textSize="20sp"/>

    Read the article

  • Any reason why my $.ajax success callback is not executed in Jquery?

    - by arma
    Hello, Today i discovered that my dev version of my website do not execute success callback, but all other javascript and jquery code is running good. Even my ajax request is performed and i can see response in firebug. $('#login').submit(function(){ var email = $('#l_email').val(); var pass = $('#l_pass').val(); if(email && pass != ''){ var str = decodeURIComponent($(this).serialize()); $.ajax({ type: "POST", url: "login.php", data: str, success: function(msg){ if(msg == 'OK'){ window.location = 'index.php' }else if (msg == 'NOT_OK'){ if(lang == 'lv'){ alert(message); }else if(lang == 'ru'){ alert(message); } }else if (msg == 'EMAIL_NOT_VALID'){ if(lang == 'lv'){ alert(message); }else if(lang == 'ru'){ alert(message); } } } }); }else{ alert('That form is empty.'); } return false; }); The thing is $.ajax part executes fine and i can see response in firebug "OK". But redirect is not happening and even if i replace that redirect with something like alert or console.log nothing comes up. What could cause this? It's really hard to track since firebug gives no errors.

    Read the article

  • search a listview in Persian

    - by user3641353
    I have listview with textview which I use textview for search items in listview. It works true but just in English. I can not change the keyboard to Persian. Do you have any solution? this is my code: ArrayAdapter<String> adapter; String[] allMovesStr = {"??? ???? ????","?? ???? ????","?? ???? ????? ???????"}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.all_moves); adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, allMovesStr); setListAdapter(adapter); EditText ed = (EditText) findViewById(R.id.inputSearch); ListView lv = (ListView) findViewById(android.R.id.list); lv.setTextFilterEnabled(true); ed.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } public void afterTextChanged(Editable arg0) { // vaghti kar bar harfi vared kard josteju mikone : AllMoves.this.adapter.getFilter().filter(arg0); } }); }

    Read the article

  • How to make the TextView invisible when there are items in listView?

    - by Raphael Thomas Liewl
    I like to display textView when there are no items in the listView whereas the textView will not display when there are items in the listView. My problem is even there are items in the listView, the textView still will be displayed in a short time and then load the items into listView. So, how to make the TextView invisible when there are items in listView? Here is the codes: public void onCreate(Bundle savedInstancesState){ super.onCreate(savedInstancesState); setContentView(R.layout.list_screen); user = getIntent().getExtras().getString("user"); Log.d("dg",user); getList(); lv = (ListView) findViewById(android.R.id.list); emptyText = (TextView)findViewById(android.R.id.empty); lv.setEmptyView(emptyText); } list_screen.xml <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <TextView android:id="@+id/android:empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/no_friend" android:gravity="center_vertical|center_horizontal"/> </LinearLayout>

    Read the article

  • Interesting Scala typing solution, doesn't work in 2.7.7?

    - by djc
    I'm trying to build some image algebra code that can work with images (basically a linear pixel buffer + dimensions) that have different types for the pixel. To get this to work, I've defined a parametrized Pixel trait with a few methods that should be able to get used with any Pixel subclass. (For now, I'm only interested in operations that work on the same Pixel type.) Here it is: trait Pixel[T <: Pixel[T]] { def mul(v: Double): T def max(v: T): T def div(v: Double): T def div(v: T): T } Now I define a single Pixel type that has storage based on three doubles (basically RGB 0.0-1.0), I've called it TripleDoublePixel: class TripleDoublePixel(v: Array[Double]) extends Pixel[TripleDoublePixel] { var data: Array[Double] = v def this() = this(Array(0.0, 0.0, 0.0)) def toString(): String = { "(" + data(0) + ", " + data(1) + ", " + data(2) + ")" } def increment(v: TripleDoublePixel) { data(0) += v.data(0) data(1) += v.data(1) data(2) += v.data(2) } def mul(v: Double): TripleDoublePixel = { new TripleDoublePixel(data.map(x => x * v)) } def div(v: Double): TripleDoublePixel = { new TripleDoublePixel(data.map(x => x / v)) } def div(v: TripleDoublePixel): TripleDoublePixel = { var tmp = new Array[Double](3) tmp(0) = data(0) / v.data(0) tmp(1) = data(1) / v.data(1) tmp(2) = data(2) / v.data(2) new TripleDoublePixel(tmp) } def max(v: TripleDoublePixel): TripleDoublePixel = { val lv = data(0) * data(0) + data(1) * data(1) + data(2) * data(2) val vv = v.data(0) * v.data(0) + v.data(1) * v.data(1) + v.data(2) * v.data(2) if (lv > vv) (this) else v } } Now I want to write code to use this, that doesn't have to know what type the pixels are. For example: def idiv[T](a: Image[T], b: Image[T]) { for (i <- 0 until a.data.size) { a.data(i) = a.data(i).div(b.data(i)) } } Unfortunately, this doesn't compile: (fragment of lindet-gen.scala):145: error: value div is not a member of T a.data(i) = a.data(i).div(b.data(i)) I was told in #scala that this worked for someone else, but that was on 2.8. I've tried to get 2.8-rc1 going, but it doesn't compile for me. Is there any way to get this to work in 2.7.7?

    Read the article

  • how to retrieve data from db and display it in list?

    - by raji
    In the below code I am passing catID to db.getNews(catID) super.onCreate(savedInstanceState); setContentView(R.layout.newslist); Bundle extras = getIntent().getExtras(); int catID = extras.getInt("cat_id"); mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ListView lv = (ListView) findViewById(R.id.category); lv.setAdapter(new ArrayAdapter<String>(this, R.layout.newslist, db.getNews(catID)){ public View getView(int position, View convertView, ViewGroup parent) { View row; if (null == convertView) { row = mInflater.inflate(R.layout.newslist, null); } else { row = convertView; } TextView tv = (TextView) row.findViewById(R.id.newslist_text); tv.setText(getItem(position)); return row; } }); the getnews(int catid) function is below: public NewsItemCursor getNews(int catID) { String sql = "SELECT title FROM news WHERE catid = " + catID + " ORDER BY id ASC"; SQLiteDatabase d = getReadableDatabase(); NewsItemCursor c = (NewsItemCursor) d.rawQueryWithFactory( new NewsItemCursor.Factory(), sql, null, null); c.moveToFirst(); d.close(); return c; } But I'm getting bug as array adapter undefined... Can anyone help me to resolve this, and retrieve data to make it display in list.

    Read the article

  • Remotely from Chrome or IE page loads ~60seconds, from Firefox or IE on local machine - instantly.

    - by Janis Veinbergs
    The problem: If i access SharePoint from Windows 7 with IE8 or Chrome5 - I must wait for like a minute to get a response. If i use other Windows 7 with IE8, just the same - just wait a MINUTE. If i use Firefox3.6 on W7 machine - page opens up instantly. Now switch to IE rendering engine in Firefox, you will have to wait just as with IE. Now i tried IE8 on XP SP3 - page opens up instantly. I tried IE8 on Windows Server 2003 SP2 (machine on which SharePoint is hosted) - page opens up instantly. IIS6 Logs I did request almost instantly from all 3 browsers and this is what shows up in IIS logs (first 2 entries for each browser): Chrome Ok, IIS saw first Chrome request when i Hit enter in browser, but i had to wait long for things to move on 2010-06-01 05:46:04 W3SVC1794621940 192.168.0.9 GET /sapulces - 80 - 192.168.0.186 Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+en-US)+AppleWebKit/533.4+(KHTML,+like+Gecko)+Chrome/5.0.375.55+Safari/533.4 401 2 2148074254 Loading... 2010-06-01 05:47:07 W3SVC1794621940 192.168.0.9 GET /sapulces - 80 - 192.168.0.186 Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+en-US)+AppleWebKit/533.4+(KHTML,+like+Gecko)+Chrome/5.0.375.55+Safari/533.4 401 1 0 ... etc... Firefox All Instantly 2010-06-01 05:46:06 W3SVC1794621940 192.168.0.9 GET /sapulces - 80 - 192.168.0.186 Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+lv;+rv:1.9.2.3)+Gecko/20100401+Firefox/3.6.3 401 2 2148074254 2010-06-01 05:46:06 W3SVC1794621940 192.168.0.9 GET /sapulces - 80 - 192.168.0.186 Mozilla/5.0+(Windows;+U;+Windows+NT+6.1;+lv;+rv:1.9.2.3)+Gecko/20100401+Firefox/3.6.3 401 1 0 ... etc... IE I did hit enter when it was 05:46:06, but these are first entries in IIS logs 2010-06-01 05:47:08 W3SVC1794621940 192.168.0.9 GET /sapulces - 80 - 192.168.0.186 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.1;+Trident/4.0;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+Media+Center+PC+6.0;+Tablet+PC+2.0;+.NET+CLR+1.1.4322;+.NET4.0C;+.NET4.0E) 401 1 0 2010-06-01 05:47:08 W3SVC1794621940 192.168.0.9 GET /sapulces - 80 - 192.168.0.186 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.1;+Trident/4.0;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+Media+Center+PC+6.0;+Tablet+PC+2.0;+.NET+CLR+1.1.4322;+.NET4.0C;+.NET4.0E) 401 1 0 ... etc... Nothing to see in Event Logs. The question Similar question has been asked but there is no response and i`m trying to access page without SSL and that happens even on GET requests. Where do I look? Where would be the problem? Browser? OS? I don't even know what to think about. Just a note Just a note about chrome's process isolation: I found it sad that while I was waiting that minute with Chrome, i could not use any other tab (i could switch, but i could not, for example, scroll or use any controls)

    Read the article

  • Can I enable discards on a LUKS-encrypted ssd drive in RHEL6 (and do I need to)?

    - by Dan Nestor
    I have a RHEL 6.4 workstation, running on a LUKS-encrypted LV residing on a SSD. I found RedHat documentation stating that dm_crypt does not currently support TRIM passthrough, however I also found other sources that state the opposite (albeit for other distributions) and even that discards are not needed for recent SSD drives which use some sort of automatic garbage collection. So: 1) Can I enable TRIM/discards with my setup? 2) Do I need to, for optimal disk performance? Thanks for your thoughts.

    Read the article

  • Can't create LVM due to: not found (or ignored by filtering)

    - by James
    I'm planning to use LVM for KVM, and when I try to create a VG it fails, so how can I create my VG and LV ? Thanks [root@server ~]# vgcreate virtual-machines /dev/sda Device /dev/sda not found (or ignored by filtering). Unable to add physical volume '/dev/sda' to volume group 'virtual-machines'. [root@server ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 2.0T 929G 976G 49% / tmpfs 3.9G 124K 3.9G 1% /dev/shm /dev/sda1 194M 57M 128M 31% /boot [root@server ~]# pvscan No matching physical volumes found

    Read the article

  • Why my button can trigger the UI to scroll and my TimerTask inside the activity can't?

    - by Spidey
    Long Story Short: a method of my activity updates and scrolls the ListView through an ArrayAdapter like it should, but a method of an internal TimerTask for polling messages (which are displayed in the ListView) updates the ListView, but don't scroll it. Why? Long Story: I have a chat activity with this layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#fff" > <ListView android:id="@+id/messageList" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stackFromBottom="true" android:transcriptMode="alwaysScroll" android:layout_weight="1" android:fadeScrollbars="true" /> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" > <EditText android:id="@+id/message" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" /> <Button android:id="@+id/button_send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Send" android:onClick="sendMessage" /> </LinearLayout> </LinearLayout> The internal listView (with id messageList) is populated by an ArrayAdapter which inflates the XML below and replaces strings in it. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="false" android:background="#fff" android:paddingLeft="2dp" android:paddingRight="2dp" > <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16sp" android:textColor="#00F" android:typeface="monospace" android:text="2010-10-12 12:12:03" android:gravity="left" /> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/sender" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="16sp" android:textColor="#f84" android:text="spidey" android:gravity="right" android:textStyle="bold" /> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/body" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="14sp" android:padding="1dp" android:gravity="left" android:layout_below="@id/date" android:text="Mensagem muito legal 123 quatro cinco seis." android:textColor="#000" /> </RelativeLayout> The problem is: in the main layout, I have a EditText for the chat message, and a Button to send the message. I have declared the adapter in the activity scope: public class ChatManager extends Activity{ private EditText et; private ListView lv; private Timestamp lastDate = null; private long campaignId; private ChatAdapter ca; private List<ChatMessage> vetMsg = new ArrayList<ChatMessage>(); private Timer chatPollingTimer; private static final int CHAT_POLLING_PERIOD = 10000; ... } So, inside sendMessage(View v), the notifyDataSetChanged() scrolls the ListView acordingly, so I can see the latest chat messages automatically: public void sendMessage(View v) { String msg = et.getText().toString(); if(msg.length() == 0){ return; } et.setText(""); String xml = ServerCom.sendAndGetChatMessages(campaignId, lastDate, msg); Vector<ChatMessage> vetNew = Chat.parse(new InputSource(new StringReader(xml))); //Pegando a última data if(!vetNew.isEmpty()){ lastDate = vetNew.lastElement().getDateSent(); //Atualizando a tela vetMsg.addAll(vetNew); ca.notifyDataSetChanged(); } } But inside my TimerTask, I can't. The ListView IS UPDATED, but it just don't scroll automatically. What am I doing wrong? private class chatPollingTask extends TimerTask { @Override public void run() { String xml; if(lastDate != null){ //Chama o Updater xml = ServerCom.getChatMessages(campaignId, lastDate); }else{ //Chama o init denovo xml = ServerCom.getChatMessages(campaignId); } Vector<ChatMessage> vetNew = Chat.parse(new InputSource(new StringReader(xml))); if(!(vetNew.isEmpty())){ //TODO: descobrir porque o chat não está rolando quando chegam novas mensagens //Descobrir também como forçar o rolamento, enquanto o bug não for corrigido. Log.d("CHAT", "New message(s) acquired!"); lastDate = vetNew.lastElement().getDateSent(); vetMsg.addAll(vetNew); ca.notifyDataSetChanged(); } } } How can I force the scroll to the bottom? I've tried using scrollTo using lv.getBottom()-lv.getHeight(), but didn't work. Is this a bug in the Android SDK? Sorry for the MASSIVE amount of code, but I guess this way the question gets pretty clear.

    Read the article

  • Drawing lines between views in a TableLayout

    - by RiThBo
    Firstly - sorry if you saw my other question which I deleted. My question was flawed. Here is a better version If I have two views, how do I draw a (straight) line between them when one of them is touched? The line needs to be dynamic so it can follow the finger until it reaches the second view where it "locks on". So, when view1 is touched a straight line is drawn which then follows the finger until it reaches view2. I created a LineView class that extends view, but I don't how to proceed. I read some tutorials but none show how to do this. I think I need to get the coordinates of both view, and then create a path which "updates" on MotionEvent. I can get the coordinates and the ids of the views I want to draw a line between, but the line that I try to draw between them either goes above it, or the line does not reach past the width and height of the view. Any advice/code/clarity would be much appreciated! Here is some code: My layout. I want to draw a line between two views contained in theTableLayout.# <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_game_relative_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TableLayout android:layout_marginTop="35dp" android:layout_marginBottom="35dp" android:id="@+id/tableLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" > <TableRow android:id="@+id/table_row_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dip" > <com.example.view.DotView android:id="@+id/game_dot_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" /> <com.example.view.DotView android:id="@+id/game_dot_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" /> <com.example.view.DotView android:id="@+id/game_dot_3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" /> </TableRow> <TableRow android:id="@+id/table_row_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dip" > <com.example.view.DotView android:id="@+id/game_dot_7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" /> <com.example.view.DotView android:id="@+id/game_dot_8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" /> <com.example.dotte.DotView android:id="@+id/game_dot_9" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="10dp" /> </TableRow> </TableLayout> </RelativeLayout> This is my LineView class. I use this to try and draw the actual line between the points. public class LineView extends View { Paint paint = new Paint(); float startingX, startingY, endingX, endingY; public LineView(Context context) { super(context); // TODO Auto-generated constructor stub paint.setColor(Color.BLACK); paint.setStrokeWidth(10); } public void setPoints(float startX, float startY, float endX, float endY) { startingX = startX; startingY = startY; endingX = endX; endingY = endY; invalidate(); } @Override public void onDraw(Canvas canvas) { canvas.drawLine(startingX, startingY, endingX, endingY, paint); } } And this is my Activity. public class Game extends Activity { DotView dv1, dv2, dv3, dv4, dv5, dv6, dv7; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_game); getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LOW_PROFILE); findDotIds(); RelativeLayout rl = (RelativeLayout) findViewById(R.id.activity_game_relative_layout); LineView lv = new LineView(this); lv.setPoints(dv1.getLeft(), dv1.getTop(), dv7.getLeft(), dv7.getTop()); rl.addView(lv); // TODO: Get the coordinates of all the dots in the TableLayout. Use view tree observer. } private void findDotIds() { // TODO Auto-generated method stub dv1 = (DotView) findViewById(R.id.game_dot_1); dv2 = (DotView) findViewById(R.id.game_dot_2); dv3 = (DotView) findViewById(R.id.game_dot_3); dv4 = (DotView) findViewById(R.id.game_dot_4); dv5 = (DotView) findViewById(R.id.game_dot_5); dv6 = (DotView) findViewById(R.id.game_dot_6); dv7 = (DotView) findViewById(R.id.game_dot_7); } } The views I want to draw lines between are in the TableLayout.

    Read the article

  • Ubuntu server on VM outgoing network(ping google.com) working, incoming(127.0.0.1:8080) is not. Was working previusly

    - by IvarsB
    I have recently installed Ubuntu server with LAMP,OpenSSH and mail on Oracle's VM, it's incoming networking was recently working, apache's default message could be seen when opening 127.0.0.1:8080. But now it's not! :( Could you give me any tips? I couldn't google anything that helped me. :( I'm running windows 7 with such settings http://www.bildites.lv/images/3d91ikwtraw0ld7lhv.png I recently used apt-get --purge remove phpmyadmin. Could that be the problem? How should I fix it? Thank you in advance! Ivars. EDIT: Sorry for the lame formating.

    Read the article

  • JavaNullPointerException/Layout Error when working with lists and ListView on Android

    - by psyhclo
    Hey, I'm trying to implement a ListView on Android, which will print the data retrieved from the SQLite Database. So I want to retrieve a lot of columns from the table and add this to a list, so I will print this list as a ListView. For this I created a method that will select all the columns from the table in a separate class, and I will print the ListView in a ListActivity. I want to retrieve 6 columns of the table, which is represented by the ids 2, 4, 5, 6, 7, 9. But it shows a lot of errors: 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): FATAL EXCEPTION: main 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): java.lang.NullPointerException 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.AbsListView.obtainView(AbsListView.java:1418) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ListView.makeAndAddView(ListView.java:1745) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ListView.fillDown(ListView.java:670) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ListView.fillFromTop(ListView.java:727) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.ListView.layoutChildren(ListView.java:1598) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.AbsListView.onLayout(AbsListView.java:1248) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.View.layout(View.java:7175) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.os.Handler.dispatchMessage(Handler.java:99) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.os.Looper.loop(Looper.java:123) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at android.app.ActivityThread.main(ActivityThread.java:3647) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at java.lang.reflect.Method.invokeNative(Native Method) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at java.lang.reflect.Method.invoke(Method.java:507) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 12-24 19:19:04.066: ERROR/AndroidRuntime(22630): at dalvik.system.NativeStart.main(Native Method) Here is the code of the method that select the data. public List<String> selectAll() { List<String> list1 = new ArrayList<String>(); List<String> list2 = new ArrayList<String>(); List<String> list3 = new ArrayList<String>(); List<String> list4 = new ArrayList<String>(); List<String> list5 = new ArrayList<String>(); List<String> list6 = new ArrayList<String>(); Cursor cursor = this.db.query(TABLE_NAME, null, null, null, null, null, "duration desc"); if (cursor.moveToFirst()) { do { list1.add(cursor.getString(2)); list2.add(cursor.getString(4)); list3.add(cursor.getString(5)); list4.add(cursor.getString(6)); list5.add(cursor.getString(7)); list6.add(cursor.getString(9)); list1.addAll(list2); list1.addAll(list3); list1.addAll(list4); list1.addAll(list5); list1.addAll(list6); } while (cursor.moveToNext()); Log.i(TAG, "After cursor.moveToNext()"); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } Log.i(TAG, "Before selectAll returnment"); return list1; } And here is the code of the ListActivity class: public class RatedCalls extends ListActivity { private static final String LOG_TAG = "RatedCallsActivity"; private CallDataHelper cdh; StringBuilder sb = new StringBuilder(); OpenHelper openHelper = new OpenHelper(RatedCalls.this); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(LOG_TAG, "calling from onCreate()"); cdh = new CallDataHelper(this); Log.i(LOG_TAG, "--->>> before calling the service"); startService(new Intent(this, RatedCallsService.class)); Log.i(LOG_TAG, "Service called."); Log.i(LOG_TAG, "--->>> after calling the service"); fillList(); } public void fillList() { List<String> ratedCalls = this.cdh.selectAll(); setListAdapter(new ArrayAdapter<String>(this, R.layout.listitem, ratedCalls)); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // When clicked, show a toast with the TextView text Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show(); } }); } }

    Read the article

  • Not able to get data from Json completely

    - by Abhinav Raja
    i am getting JSON data from http://abinet.org/?json=1 and displaying the titles in a ListView. the code is working fine but the problem is, it is skipping few titles in my ListView and one title is being repeated. You can see the json data from url given above by copy paste it in JSON editor online http://www.jsoneditoronline.org/ i want titles in the "posts" array to be displayed in ListView, however it is being displayed like this: if you see the JSON data from the link above, its missing like 3 titles (they should come between the first and second title) and 5th title is being repeated. Dont know why this is happening. What minor adjustments i need to do? Please help me. this is my code : public class MainActivity extends Activity { // URL to get contacts JSON private static String url = "http://abinet.org/?json=1"; // JSON Node names private static final String TAG_POSTS = "posts"; static final String TAG_TITLE = "title"; private ProgressDialog pDialog; JSONArray contacts = null; TextView img_url; ArrayList<HashMap<String, Object>> contactList; ListView lv; LazyAdapter adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); lv = (ListView) findViewById(R.id.newslist); contactList = new ArrayList<HashMap<String, Object>>(); new GetContacts().execute(); } private class GetContacts extends AsyncTask<Void, Void, Void> { protected void onPreExecute() { super.onPreExecute(); // Showing progress dialog pDialog = new ProgressDialog(MainActivity.this); pDialog.setMessage("Please wait..."); pDialog.setCancelable(false); pDialog.show(); } protected Void doInBackground(Void... arg0) { // Making a request to url and getting response JSONParser jParser = new JSONParser(); // Getting JSON from URL JSONObject jsonObj = jParser.getJSONFromUrl(url); // if (jsonStr != null) { try { // Getting JSON Array node contacts = jsonObj.getJSONArray(TAG_POSTS); // looping through All Contacts for (int i = 0; i < contacts.length(); i++) { // JSONObject c = contacts.getJSONObject(i); JSONObject posts = contacts.getJSONObject(i); String title = posts.getString(TAG_TITLE).replace("&#8217;", "'"); JSONArray attachment = posts.getJSONArray("attachments"); for (int j = 0; j< attachment.length(); j++){ JSONObject obj = attachment.getJSONObject(j); JSONObject image = obj.getJSONObject("images"); JSONObject image_small = image.getJSONObject("thumbnail"); String imgurl = image_small.getString("url"); HashMap<String, Object> contact = new HashMap<String, Object>(); contact.put("image_url", imgurl); contact.put(TAG_TITLE, title); contactList.add(contact); } } } catch (JSONException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); // Dismiss the progress dialog if (pDialog.isShowing()) pDialog.dismiss(); adapter=new LazyAdapter(MainActivity.this, contactList); lv.setAdapter(adapter); } } } this is my JsonParser class (although its not required): public JSONParser() { } public JSONObject getJSONFromUrl(String url) { // Making HTTP request try { // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "n"); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } // return JSON String return jObj; } } and this is adapter class: public class LazyAdapter extends BaseAdapter { private Activity activity; private ArrayList<HashMap<String, Object>> data; private static LayoutInflater inflater=null; public LazyAdapter(Activity a,ArrayList<HashMap<String, Object>> d) { activity = a; data=d; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { View vi=convertView; if(convertView==null) vi = inflater.inflate(R.layout.third_row, null); TextView title = (TextView)vi.findViewById(R.id.headline3); // title SmartImageView iv = (SmartImageView) vi.findViewById(R.id.imageicon); HashMap<String, Object> song = new HashMap<String, Object>(); song = data.get(position); // Setting all values in listview title.setText((CharSequence) song.get(MainActivity.TAG_TITLE)); iv.setImageUrl((String) song.get("image_url")); thumb_image); return vi; } } Please help me. I am stuck at this for more than a week now. I think there is just something to be changed in my MainActivity class.

    Read the article

  • C++ addition overload ambiguity

    - by Nate
    I am coming up against a vexing conundrum in my code base. I can't quite tell why my code generates this error, but (for example) std::string does not. class String { public: String(const char*str); friend String operator+ ( const String& lval, const char *rval ); friend String operator+ ( const char *lval, const String& rval ); String operator+ ( const String& rval ); }; The implementation of these is easy enough to imagine on your own. My driver program contains the following: String result, lval("left side "), rval("of string"); char lv[] = "right side ", rv[] = "of string"; result = lv + rval; printf(result); result = (lval + rv); printf(result); Which generates the following error in gcc 4.1.2: driver.cpp:25: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: String.h:22: note: candidate 1: String operator+(const String&, const char*) String.h:24: note: candidate 2: String String::operator+(const String&) So far so good, right? Sadly, my String(const char *str) constructor is so handy to have as an implicit constructor, that using the explicit keyword to solve this would just cause a different pile of problems. Moreover... std::string doesn't have to resort to this, and I can't figure out why. For example, in basic_string.h, they are declared as follows: template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT,_Traits,_Alloc> operator+(const _CharT* __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs); and so on. The basic_string constructor is not declared explicit. How does this not cause the same error I'm getting, and how can I achieve the same behavior??

    Read the article

  • Adding multiple views to a listview.

    - by hwrdprkns
    Hey guys, I tried to add these views to list view using this kind of factory but everytime I try and add the view to a ListActivity, it comes up with nothing. What am I doing wrong? I set my list views like so: List<View> views = new ArrayList<View>(); for(int x =0;x<tagg_views.size();x++) { lv.addHeaderView(views.get(x)); }

    Read the article

  • No device file for partition on logical volume (Linux LVM)

    - by Brian
    I created a logical volume (scandata) containing a single ext3 partition. It is the only logical volume in its volume group (case4t). Said volume group is comprised by 3 physical volumes, which are three primary partitions on a single block device (/dev/sdb). When I created it, I could mount the partition via the block device /dev/mapper/case4t-scandatap1. Since last reboot the aforementioned block device file has disappeared. It may be of note -- I'm not sure -- that my superior (a college professor) had prompted this reboot by running sudo chmod -R [his name] /usr/bin, which obliterated all suid in its path, preventing the both of us from sudo-ing. That issue has been (temporarily) rectified via this operation. Now I'll cut the chatter and get started with the terminal dumps: $ sudo pvs; sudo vgs; sudo lvs Logging initialised at Sat Jan 8 11:42:34 2011 Set umask to 0077 Scanning for physical volume names PV VG Fmt Attr PSize PFree /dev/sdb1 case4t lvm2 a- 819.32G 0 /dev/sdb2 case4t lvm2 a- 866.40G 0 /dev/sdb3 case4t lvm2 a- 47.09G 0 Wiping internal VG cache Logging initialised at Sat Jan 8 11:42:34 2011 Set umask to 0077 Finding all volume groups Finding volume group "case4t" VG #PV #LV #SN Attr VSize VFree case4t 3 1 0 wz--n- 1.69T 0 Wiping internal VG cache Logging initialised at Sat Jan 8 11:42:34 2011 Set umask to 0077 Finding all logical volumes LV VG Attr LSize Origin Snap% Move Log Copy% Convert scandata case4t -wi-a- 1.69T Wiping internal VG cache $ sudo vgchange -a y Logging initialised at Sat Jan 8 11:43:14 2011 Set umask to 0077 Finding all volume groups Finding volume group "case4t" 1 logical volume(s) in volume group "case4t" already active 1 existing logical volume(s) in volume group "case4t" monitored Found volume group "case4t" Activated logical volumes in volume group "case4t" 1 logical volume(s) in volume group "case4t" now active Wiping internal VG cache $ ls /dev | grep case4t case4t $ ls /dev/mapper case4t-scandata control $ sudo fdisk -l /dev/case4t/scandata Disk /dev/case4t/scandata: 1860.5 GB, 1860584865792 bytes 255 heads, 63 sectors/track, 226203 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00049bf5 Device Boot Start End Blocks Id System /dev/case4t/scandata1 1 226203 1816975566 83 Linux $ sudo parted /dev/case4t/scandata print Model: Linux device-mapper (linear) (dm) Disk /dev/mapper/case4t-scandata: 1861GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 1861GB 1861GB primary ext3 $ sudo fdisk -l /dev/sdb Disk /dev/sdb: 1860.5 GB, 1860593254400 bytes 255 heads, 63 sectors/track, 226204 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00000081 Device Boot Start End Blocks Id System /dev/sdb1 1 106955 859116006 83 Linux /dev/sdb2 113103 226204 908491815 83 Linux /dev/sdb3 106956 113102 49375777+ 83 Linux Partition table entries are not in disk order $ sudo parted /dev/sdb print Model: DELL PERC 6/i (scsi) Disk /dev/sdb: 1861GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 880GB 880GB primary reiserfs 3 880GB 930GB 50.6GB primary 2 930GB 1861GB 930GB primary I find it a bit strange that partition one above is said to be reiserfs, or if it matters -- it was previously reiserfs, but LVM recognizes it as a PV. To reiterate, neither /dev/mapper/case4t-scandatap1 (which I had used previously) nor /dev/case4t/scandata1 (as printed by fdisk) exists. And /dev/case4t/scandata (no partition number) cannot be mounted: $sudo mount -t ext3 /dev/case4t/scandata /mnt/new mount: wrong fs type, bad option, bad superblock on /dev/mapper/case4t-scandata, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so All I get on syslog is: [170059.538137] VFS: Can't find ext3 filesystem on dev dm-0. Thanks in advance for any help you can offer, Brian P.S. I am on Ubuntu GNU/Linux 2.6.28-11-server (Jaunty) (out of date, I know -- that's on the laundry list).

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >