|
Member 11897566 wrote: its not working You need to explain what that actually means. We cannot guess what you have done, or what results you see.
|
|
|
|
|
what I mean by not working is that its not taking effect when I run in on my device, and I don't have any errors in the logcat window or any. but when I change the background color of the main content or inside the linear layout for ex. and run on my device and it does take effect it changed the background color.
I use the theme.holo.light. and the way I code it like this.
in the style.XML inside resource tag
<item name="android:background">#rrggbb color code</item
|
|
|
|
|
|
Hi all, I have a TableLayout nested within a ScrollView / LinearLayout, I add rows to the table dynamically when the application starts, the problem I have is I'm only seeing a third of my tables rows e.g. if I have 30 rows I can only scroll down to row 10 - my layout is as shown below - can anyone see anything wrong with this layout ? It displays and works perfectly for the rows that are visible ( please excuse the formatting )
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tablelayoutmain"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="20dp"
android:gravity="fill">
</TableLayout>
</LinearLayout>
</ScrollView>
We can’t stop here, this is bat country - Hunter S Thompson RIP
modified 25-Jul-15 5:29am.
|
|
|
|
|
I just tried using that exact layout, with a dynamically filled table of 40 rows each of 5 columns, and it scrolls fine top to bottom. Maybe you need to show us something more.
|
|
|
|
|
Hi Richard, thanks for replying - I should have said I'm adding ListViews to my table rows which I've read are problematic in ScrollViews but if it works for ten rows it should work ( to my mind ) with any amount
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
Pete, would you like to share some code? It may be that the view handler is getting confused by the multi-level scrolling. My sample test just added some textviews to each row.
|
|
|
|
|
I just tried it and had the same problem using a ListView in each row. It looks like the view manager is taking the count of rows in each ListView item into account when calculating how far it scrolls, and getting confused. This may well be an Android restriction rather than a bug, but who knows?
|
|
|
|
|
I agree, thanks very much for your efforts - do you use Android Studio ? just being nosey.
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
Just for your information, I tried removing the LinearLayout to see what would happen and I got all of my rows but only the ListView header was visible and the ListView itself is scrollable ( but too small to be of any use ).
We can’t stop here, this is bat country - Hunter S Thompson RIP
modified 26-Jul-15 7:14am.
|
|
|
|
|
|
Putting Richard's reply simply, we also need to see the Java code that you are using. That would explain the problem. This XML is just the layout for your application's activity, Java would show how this layout is actually rendered and other similar things.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hi Afzaal, see Richards latest reply - thanks for replying.
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
please mention horizontal view or vertical view in your lay out then only it will get scroll.In list view scroll will be automatically called when the items get increased
|
|
|
|
|
Hi there, if you read my original post you will see that my view does scroll but it only shows a third of the rows
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
Dear Expert,
I am in level 0 of android programming.
I need to know how to start learning?
What are the software used to build Android application?
What is the latest software used to build the applications?
Regards,
|
|
|
|
|
|
|
Steps to configure Android SDK
Step 1 - Setup Java Development Kit (JDK): You can download the latest version of Java JDK from Oracle's Java site
Step 2 - Setup Android SDK: You can download the latest version of Android SDK from Android official website
Step 3 - Setup Eclipse IDE
Step 4 - Setup Android Development Tools (ADT) Plugin
Step 5 - Create Android Virtual Device
|
|
|
|
|
When I run my app in Android Studio I get the message "Unfortunately your App Appointment DB has stopped working". Not sure how to resolve this issue. Here is my code.
MainActivity.java
package com.example.android.appointmentdb;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
TextView idView;
EditText clientNameBox;
EditText clientPhoneBox;
EditText clientTimeBox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
idView = (TextView) findViewById(R.id.clientID);
clientNameBox = (EditText) findViewById(R.id.clientName);
clientPhoneBox =(EditText) findViewById(R.id.clientPhone);
clientTimeBox =(EditText) findViewById(R.id.clientTime);
}
public void newClient (View view) {
MyDBHandler dbHandler = new MyDBHandler(this, null, null, 1);
String phone = clientPhoneBox.getText().toString();
String name = clientNameBox.getText().toString();
String time = clientTimeBox.getText().toString();
Appointment newAppointment = new Appointment(name, phone, time);
dbHandler.addClient(newAppointment);
Toast.makeText(getApplicationContext(), "Your appointment is set =)",
Toast.LENGTH_LONG).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
MyDBHandler.java
package com.example.android.appointmentdb;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.content.Context;
import android.content.ContentValues;
import android.database.Cursor;
public class MyDBHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "thursdayDB.db";
private static final String TABLE_APPOINTMENTS = "7-16-2015";
public static final String COLUMN_ID = "_id";
public static final String COLUMN_CLIENTNAME = "clientname";
public static final String COLUMN_CLIENTPHONE = "clientphone";
public static final String COLUMN_CLIENTTIME = "clienttime";
public MyDBHandler(Context context, String name,
SQLiteDatabase.CursorFactory factory, int version) {
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_PRODUCTS_TABLE = "CREATE TABLE " +
TABLE_APPOINTMENTS + "("
+ COLUMN_ID + " INTEGER PRIMARY KEY,"
+ COLUMN_CLIENTNAME+ " TEXT,"
+ COLUMN_CLIENTPHONE + " TEXT,"
+ COLUMN_CLIENTTIME + " TEXT" + ")";
db.execSQL(CREATE_PRODUCTS_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion,
int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_APPOINTMENTS);
onCreate(db);
}
public void addClient(Appointment appointment) {
ContentValues values = new ContentValues();
values.put(COLUMN_CLIENTNAME, appointment.getClientName());
values.put(COLUMN_CLIENTPHONE, appointment.getClientPhone());
values.put(COLUMN_CLIENTTIME, appointment.getClientTime());
SQLiteDatabase db = this.getWritableDatabase();
db.insert(TABLE_APPOINTMENTS, null, values);
db.close();
}
public Appointment findAppointment(String clientname) {
String query = "Select * FROM " + TABLE_APPOINTMENTS + " WHERE " + COLUMN_CLIENTNAME + " = \"" + clientname + "\"";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
Appointment appointment = new Appointment();
if (cursor.moveToFirst()) {
cursor.moveToFirst();
appointment.setID(Integer.parseInt(cursor.getString(0)));
appointment.setClientName(cursor.getString(1));
appointment.setClientPhone(cursor.getString(2));
appointment.setClientTime(cursor.getString(3));
cursor.close();
} else {
appointment = null;
}
db.close();
return appointment;
}
}
Appointment.java
package com.example.android.appointmentdb;
public class Appointment {
private int _id;
private String _clientName;
private String _clientPhone;
private String _clientTime;
public Appointment() {
}
public Appointment(int id, String clientName, String clientPhone, String clientTime) {
this._id = id;
this._clientName = clientName;
this._clientPhone = clientPhone;
this._clientTime = clientTime;
}
public Appointment(String clientName, String clientPhone, String clientTime) {
this._clientName = clientName;
this._clientPhone = clientPhone;
this._clientTime = clientTime;
}
public void setID(int id) {
this._id = id;
}
public int getID() {
return this._id;
}
public void setClientName(String clientName) {
this._clientName = clientName;
}
public String getClientName() {
return this._clientName;
}
public void setClientTime(String clientTime) {
this._clientTime = clientTime;
}
public String getClientTime() {
return this._clientTime;
}
public void setClientPhone(String clientPhone) {
this._clientPhone = clientPhone;
}
public String getClientPhone() {
return this._clientPhone;
}
}
activity_main.xml
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/id_string"
android:id="@+id/textView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text=""
android:id="@+id/clientID" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/name_string"
android:id="@+id/textView3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/clientName" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/phone_string"
android:id="@+id/textView2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="@+id/clientPhone" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/time_string"
android:id="@+id/textView1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="time"
android:ems="10"
android:id="@+id/clientTime" />
</TableRow>
</TableLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/book_string"
android:id="@+id/button"
android:onClick="newClient"/>
</LinearLayout>
</LinearLayout>
|
|
|
|
|
Please do not just dump all your code and expect someone to debug it for you. Look at the Logcat messages to see where it crashed and what errors are reported. You can then narrow it down to see what part of your code is causing the problem, and how you can add some more code to help diagnose it.
|
|
|
|
|
I'm a beginner and wasn't able to figure out how to read log cat error messages and debug. Just looking for help not sarcasm. Thought someone might be able to easily identify the error. I'll figure it out on my own. Thanks anyway.
|
|
|
|
|
Member 11855170 wrote: Just looking for help not sarcasm. Help is what I offered you.
Member 11855170 wrote: Thought someone might be able to easily identify the error. Well we probably could have done if you had presented it to us. All you have provided is a listing of your program with no context, so we have no idea where to start looking. If you wish to become a developer then you need to spend some time getting familiar with the debugging tools in your armoury. Without them you will find things very difficult.
modified 23-Jul-15 3:49am.
|
|
|
|
|
Ok. I'll learn how to use the debugging tools. Any good tutorials? I'm using Android Studio.
|
|
|
|
|