ActionBarSherlock - How does it creates title on each xml files in layout? - android

Recently i have successfully implemented the ActionBarSherlock Demos sample in eclipse. But there is something that i am not able to understand it that how this library automatically creates the header with one icon and a text "ActionBarSharelock Demos" in tab_navigation.xml by using merely a LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="20dip">
</LinearLayout>
This library is new for me and i am so anxious to know, how this library creates it?
I created a new android project on target api 15 and attach the ActionBarSherlock library to it. then i found that there some of the files are missing from my new android project when i compared it to demos sample project of android. Those files are listed below.
1.pom.xml
2.bin/classes.dex
3.bin/jarlist.cache
4.bin/resources.ap_
Moreover i got a new error in my activity file on eclipse "R cannot be resolved to a variable."
If you know anything about my problem then please share your views.

To use the simplest example:
public class Simple extends SherlockActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(SampleList.THEME); //Used for theme switching in samples
super.onCreate(savedInstanceState);
setContentView(R.layout.text);
((TextView)findViewById(R.id.text)).setText(R.string.simple_content);
}
}
All you have to do is let your activity inherit one of the Sherlock activites (e.g., SherlockActivity, SherlockFragmentActivity).
You can program the action bar by using the getSupportActionBar() method of the SherlockActivity, e.g. to set the title: getSupportActionBar().setTitle( R.string.my_title );

Related

AppCompat v7 not being referenced properly

I'm new to Xamarin Android. I've installed the AppCompatv7 Support Library from the GetComponents option.
But whenever I try and do anything with it, I get no intellisense, like it isn't actually added to the project. Like below:
When I look more into the assembly it comes up with an option like below, saying it might not be installed. But as you can see from the picture, it is installed under my references.
If I click Add Package in the below picture, nothing happens.
When I compile the code, it can't find functions in the ActionBarActivity base class, so I'm guessing it's not adding it properly into my project.
Anyone know why this is happening? Cheers
When I compile the code, it can't find functions in the ActionBarActivity base class, so I'm guessing it's not adding it properly into my project.
ActionBarActivity is obsolete.
To use Android.Support.V7.Widget.Toolbar, after installing the Xamarin.Android.Support.v7.AppCompat package, you can simply inherit your MainActivity from AppCompatActivity instead of ActionBarActivity.
Then for example my toolbar is like this:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:layout_width="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/toolbartitile"
android:text="Kodej" />
</android.support.v7.widget.Toolbar>
Include this toolbar in Main layout like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include android:id="#+id/toolbar"
layout="#layout/mytoolbar" />
</LinearLayout>
And finally in your MainActivity:
public class MainActivity : AppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(toolbar);
}
}
You just need to reference Android.Support.V7.App in your code:
using Android.Support.V7.App;
All references in my demo:
If you've installed the libs correctly and there is no no intellisense, you can try to rebuild your app, close and reopen your VS.
Install it using the NuGet Command Console :
Install-Package Xamarin.Android.Support.v7.AppCompat -Pre

Using Crosswalk in an Android Cordova Project with Embedded WebView

I have an existing Android Cordova project which uses an embedded WebView. What this means is that the Activity does not extend CordovaActivity, but instead embeds the SystemWebView and initializes within the onCreate.
The following is currently how this is being done:
Within the layout XML file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
.... other layout elements not related to Cordova....
<org.apache.cordova.engine.SystemWebView
android:id="#+id/cdvWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
Within the Activity's onCreate:
SystemWebView systemWebView = (SystemWebView) findViewById(R.id.cdvWebView);
CordovaWebView cdvWebView = new CordovaWebViewImpl(new SystemWebViewEngine(systemWebView));
ConfigXmlParser parser = new ConfigXmlParser();
parser.parse(this);
cdvWebView.init(this, parser.getPluginEntries(), parser.getPreferences());
Due to the bug in Lollipop versions 5.0.+ missing the "set" button, I want to implement the Crosswalk plugin into the project.
Unfortunately, all the documentation I'm finding assumes that a typical Cordova install is being used. I haven't been able to get the embedding and initialization of the XWalkWebView working correctly and keep getting a blank white screen.
Has anybody has success with a similar scenario?
I'm not sure, but this might answer your question. It seems to show implementing an XWalkWebView outside of a typical cordova project:
https://github.com/kurli/crosswalk-website/wiki/How-to-use-Crosswalk-Embedded-API-on-Android

Get access to Zxing QR scanner camera view

I am new to android development and I am working on an android project where I have to integrate QR scanner. So I thought I would integrate Zxing QR scanner and came across this library https://github.com/dm77/barcodescanner, Following the instructions provided I have successfully integrated and scanned a QR as well.
Now I want to customise the camera view. The problem is there is no documentation on how to get access to the camera layout. Since I am new I might be missing something.
I have read through many Zxing related threads but I din find any solution.
Any help will be greatly appreciated either by letting me know on how I can get access to the camera view or pointing me out to some articles. Once I know how then I can complete the rest.
I would be happy to provide any further information.
Thanks in advance.
Update:
public class QrScanActivity extends BaseActivity implements ZXingScannerView.ResultHandler {
private ZXingScannerView mScannerView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_scan);
// Programmatically initialize the scanner view
mScannerView = new ZXingScannerView(this);
// Set the scanner view as the content view
setContentView(mScannerView);
}
mScannerView is the view from the library. I want to get access to that view. I have a view called as activity_my_scan. I can add custom layout to that and use that but I don't know how to bypass the layout being used by the library.
Instead of just adding this lib as a jar using gradle's
compile 'me.dm7.barcodescanner:zxing:1.6.3'
you could clone the project from github or download a zip and uzip it and integrate to your project as a lib project. And then make any desired changes in its sources and its layouts.
ZXingScannerView extends BarcodeScannerView. You can access this by going to the declaration of ZXingScannerView (in Android Studio Ctrl+B).
public class ZXingScannerView extends BarcodeScannerView {
private MultiFormatReader mMultiFormatReader;
public static final List<BarcodeFormat> ALL_FORMATS = new ArrayList();
private List<BarcodeFormat> mFormats;
private ZXingScannerView.ResultHandler mResultHandler;
If you go the declaration of BarcodeScannerView, you'll notice a method called setupLayout() which formats the layout:
public void setupLayout() {
this.mPreview = new CameraPreview(this.getContext());
this.mViewFinderView = new ViewFinderView(this.getContext());
RelativeLayout relativeLayout = new RelativeLayout(this.getContext());
relativeLayout.setGravity(17);
relativeLayout.setBackgroundColor(-16777216);
relativeLayout.addView(this.mPreview);
this.addView(relativeLayout);
this.addView(this.mViewFinderView);
}
By going to the declaration of "CameraPreview" you'll be able to get more info for how the camera is laid out and you could maybe extend ZXingScannerView to edit the layout.
Hope this helps!
Cheers!
Well in your case i would try to include the layout into another layout, maybe it helps:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:background="#color/app_bg"
android:gravity="center_horizontal">
<include layout="#layout/titlebar"/>
<TextView android:layout_width=”match_parent”
android:layout_height="wrap_content"
android:text="#string/hello"
android:padding="10dp" />
...
</LinearLayout>
And of course there is information about that here ;)

how to use android process button lib

I've download android process button lib and import it into my eclipse. :
android process button lib :
I created an android project then I added this lib into my project :
now, I want to use this library but I get this error :
ProgressGenerator cannot be resolved to a type
I am using eclipse.
#NIPHIN answer is correct. As you can notice library is using gradle folder structure.
Here are 2 options:
Move com.dd... folders to src folder.
Create new project library, and simply copy all res and classes to your new created folder.
CHeck the project structure, reorganize the folder "java" to reflect folder structure as same folder "src" in eclipse. Eclipse and Studio IDE have different folder structures.
Am not sure of how you integrated it, but the example clearly state to import
import com.dd.processbutton.iml.ActionProcessButton;
import com.dd.processbutton.iml.GenerateProcessButton;
import com.dd.processbutton.iml.SubmitProcessButton;
Even though the project has been added as a dependency library, you would still need to have these import statements. May be eclipse is having trouble automatically adding these imports? Jut add them i manually. If your folder structure and import are correct, it should work.
Thread is a bit old, but perhaps I can help you out.
I´ll show you an Example with the ActionProcessButton
first of all in your layout, u need the specific Button. For example:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.dd.processbutton.iml.ActionProcessButton
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginBottom="16dp"
android:textColor="#android:color/white"
android:textSize="18sp"
android:text="#string/login"
android:id="#+id/loginButton"
android:textAllCaps="true"
custom:pb_colorComplete="#color/green_complete"
custom:pb_colorNormal="#color/blue_normal"
custom:pb_colorPressed="#color/blue_pressed"
custom:pb_colorProgress="#color/purple_progress"
custom:pb_textComplete="#string/login_successfull"
custom:pb_textProgress="#string/login_auth" />
</RelativeLayout>
inside your activiy / Fragment / whatever:
public class LoginFragment extends Fragment {
private ActionProcessButton loginButton;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.login_fragment, container, false);
loginButton = (ActionProcessButton) view.findViewById(R.id.loginButton);
loginButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
loginButton.setProgress(50); // starts the Animation and sets the text defined in your .xml file for Progress
loginDone();
}
});
}
private void loginDone(){
//...
// do something time-consuming
loginButton.setProgress(100); // tolds the button, that your operation is done.
}
// ...
}
Of course, you can update the Progress state dynamically, but as I know, the critical values for setProgress are -1(for login failed), 0, 50 and 100.

Android GraphView 2 without labels

I am currently trying to draw a graph within an Android application. The library I found is called GraphView (http://www.jjoe64.com/p/graphview-library.html). I am currently using version 2, which is available on GitHub.
Drawing graphs works really nicely. The code necessary to get a graph is the following:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Map<String,List<GraphEntry>> graphData = (...)
if (graphData != null) {
List<GraphEntry> entries = graphData.get("temperature");
GraphView.GraphViewData[] data = new GraphView.GraphViewData[entries.size()];
int i = 0;
for (GraphEntry entry : entries) {
data[i++] = new GraphView.GraphViewData(entry.getDate().getTime(), entry.getValue());
}
GraphView.GraphViewSeries graphViewSeries = new GraphView.GraphViewSeries("temperature", 0xffff0000, data);
LineGraphView graphView = new LineGraphView(this, "temperature");
graphView.addSeries(graphViewSeries);
graphView.setShowLegend(true);
LinearLayout graphLayout = (LinearLayout) findViewById(R.id.layout);
graphLayout.addView(graphView);
}
}
This will produce a normal graph. Unfortunately, all kinds of labels are missing. The documentation tells that for the normal use case, one does not have to care about labels, as the library does this automatically. What am I doing wrong? I only get the plain graph, without any labels.
For the completeness, I am adding the graph to a linear layout. The appropriate layout file has the following contents:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:padding="5dp"
android:id="#+id/layout"
android:orientation="vertical"
></LinearLayout>
The GraphEntry class is only a container with a java.util.Date attribute and a double value attribute.
Thank you very much for any help,
Matthias
I switched to another charting engine: AChartEngine. This one works out of the box.
I had the same problem. This can be solved by removing the following line from the manifest file.
android:theme="#style/AppTheme"
I know this is quite vague, but worked for me. I don't the exact reason why this happens. If u guys come across the better solution please do share it.
You should use the latest version from github and include that in your project. This will allow you to set various colours using
graphView.getGraphViewStyle().setGridColor(Color.GREEN);
graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.YELLOW);
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.RED);

Categories

Resources